[Zope] ZCatalog queries performance

Tres Seaver tseaver at palladion.com
Tue May 19 12:50:51 CEST 2015

Hash: SHA1

On 05/19/2015 04:54 AM, Sebastian Tänzer wrote:

> Let’s say I want to display an accordion with all events of a month 
> displaying quite a lot of data about the event (30-50 events on one 
> page, collapsible jQuery accordion). At the moment I get the results
> and put the objects into the result set via unrestrictedTraverse
> using getPath(). Would it be better to only get the path and get the
> object in the template? Does this make any difference performance
> wise?

Nope.  Doing it in trusted code (an actual method, and ExternalMethod, or
a view) would be faster than either a script or a template.  Measure it
to decide whether to switch, however.

> Which data of the event objects would I keep as ZCatalog meta columns 
> and which not? Documentation is not really helpful on this.

It is super application-dependent.  The costs for maintaining "extra"
columns of metaata are relatively small (bloating the Record object, and
therefore its pickle, mostly).

> The tricky part is that events are linked with different locations 
> (event location, selling points) that are not children of the event 
> object but objects in a different folder. The event object itself
> only keeps the links to these location objects and I get them when
> iterating over the result set in the template.

If you can define a URL-addressible method of the event which returns or
redirects to those objects, you can get away with hard-wiring that in
your template, using 'brain.getPath()' as a prefix.

> Any advice what would be the best way for this performance-wise? Is
> it okay to get the object itself via traversal? Is there a faster way
> to get the object data?

Fetching the object is fast if it is already in the ZODB cache, but slow
if not, nd may cause other, more "popular" / important objects to be
evicted.  Where possible, design for catalog queries which don't need to
fetch the object.

- -- 
Tres Seaver          +1 540-429-0999          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
Version: GnuPG v1.4.11 (GNU/Linux)


More information about the Zope mailing list