[Zope] ZCatalog queries performance
Sebastian Tänzer
st at taenzer.me
Tue May 19 12:57:12 CEST 2015
Thanks, this answered all of my questions :-)
Best, Sebastian
> Am 19.05.2015 um 12:50 schrieb Tres Seaver <tseaver at palladion.com>:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> 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.
> - --
> ===================================================================
> Tres Seaver +1 540-429-0999 tseaver at palladion.com
> Palladion Software "Excellence by Design" http://palladion.com
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (GNU/Linux)
>
> iQIcBAEBAgAGBQJVWxWLAAoJEPKpaDSJE9HY0aQP/1mC0Ll5//c24XQPcvMwS18Y
> /gZfOe/IeL61CRrI2Sv+RMQ6N6gXpL8oM/KsWU2wphfPVYC96VxiD28ubhmWVk+f
> GFbmN4YchYSNHND2kzcjxyHd1+U6+c/NhkcfgL9GtLZBsSNtMZut2pV7sN7VvjhJ
> 0F1Kwu6HxZ5yvEjZOk0tzDfrhh0I4Y3elFTwJkHXq/Z/3xN+NTVNpYXRAw5AWGJC
> A0Y/ll/cx1+JIKlMbjhMNqG+k61JGD8MdZXIvBwJ7jij1VIGYfYG5/7wZieMjCTL
> /SBMkOnODchSzSk2wV1B0ZgpbgTf+DYuZRzKCrYc7QOktfQhqEBOS5ljIjpWkDcq
> wqsxPBD0uyu/K3+dd4egL3Fcvg5DDfm9//Qo2B8JAkLWO5XeJ4UiyZHLYWZXSpXI
> SdjL2zFnhTZhp9pxIv+V4W/XrzMEDAr3UOFlrikiGd4oxTBffFuxuSr2mvpqshTQ
> TaS8Vgty9SmqMaPuvMZPc7FoPExsC4k4sNO9XgSXKT/5xo3FErLTWVCL1/qVHN3I
> 6wHvSrh8n1Z/m60P6OaUzIHF/97sjbxOO75d0RZCnaTFWt2TizrrsrwaBZ2p6Yyo
> 83l5QxPLDge6EZNb1MMewZ9vW8EamDhkR2pKTsQTEVDj2p4gVhmh+J5pjN6BKj50
> D98HPv4JrWhf965/Pay4
> =Sv38
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> Zope maillist - Zope at zope.org
> https://mail.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> https://mail.zope.org/mailman/listinfo/zope-announce
> https://mail.zope.org/mailman/listinfo/zope-dev )
More information about the Zope
mailing list