[Zope-CMF] Catalog: Adding indexes or waking up objects?

Tres Seaver tseaver@zope.com
23 Aug 2002 10:25:51 -0400


On Thu, 2002-08-22 at 08:14, Rainer Thaden wrote:

> let's say we have several classes whose instances reference eachother
> in the views or edit forms e.g. an employee and projects which
> reference an employee.
> In the edit form all employees are listed by their names. To get the
> names out of the instances i first do a portal_catalog.searchResults
> and then use getObject which means waking up the object.
> Another way would be to add an index to the catalog which contains the
> name so i can pull it out of the brain.

Actually, you would add a a "schema column" to the "Metadata" tab of the
catalog, and *not* an index;  indexes are for searching, but schema
columns are what give the brains their attributes.

> Are there any recommendations on the performance of these methods
> depending on the number of objects?
> Let's say there are only up to 30 employees. Is it critical to wake up
> 30 objects?
> If i add indexes 'firstname' and 'lastname' they would be useless for
> all other types.
> Does it matter to add lots of indexes? Does the catalog performance
> decrease?

You are trading of a bit of time at the point where the object is
recatalogued, plus potentially a bit of space (objects which don't have
the corresponding attribute / method get a default value, usually None),
for improved performance when generating a report.  Thus, the right way
to evaluate the tradeoff is to consider how often objects are updated,
versus how often the report is run, and how big the set of values is.
You can also write tests which use "real enough" data to get a feel for
the relative performance on your hardware, OS, etc.

Tres.
-- 
===============================================================
Tres Seaver                                tseaver@zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com