[Zope] Catalog reindexing: field by field or not?

Dieter Maurer dieter at handshake.de
Fri Feb 20 17:51:56 EST 2004


Lennart Regebro wrote at 2004-2-20 11:50 +0100:
>I notice that when calling manage_reindexIndex with several indexes, it 
>will simply call reindexIndex once for each index.
>
>The question is, is there a performace penalty for reindexing several 
>fields separately like this, or will it always be faster to only reindex 
>the relevant indexes?

It is, as the objects are loaded over and over again from ZODB.

The implementation of "reindexIndex" is really stupid.

In our Zope installation, I changed it to:

    def manage_reindexIndex(self, ids=None, REQUEST=None, RESPONSE=None,
                            URL1=None):
        """Reindex indexe(s) from a ZCatalog"""
        if not ids:
            return MessageDialog(title='No items specified',
                message='No items were specified!',
                action = "./manage_catalogIndexes",)

        if isinstance(ids, types.StringType):
            ids = (ids,)

        # DM: what a stupid implementation -- optimize!
        # for name in ids:
        #     self.reindexIndex(name, REQUEST)
        self.reindexIndex(ids, REQUEST)
        ....

    def reindexIndex(self, name, REQUEST):
        # DM: optimize!
        idxs = isinstance(name, types.StringType) and [name] or name
	....

-- 
Dieter



More information about the Zope mailing list