Am Samstag, den 05.05.2007, 17:42 +0200 schrieb Dominique Lederer: > hi > > i would like to retrieve a number of *random* entries out of a catalogs field > index. > > i tried it with first getting the catalogindex-length an then accessing a > randomized list-index, but this is very slow, because of the large number of > entries in the index. > > do you know any better solution?
I'm kind of guessing here. You say you are: - querying the catalog - accessing a random index from the result set - noticing that this is slow Does this only happen if the index is very large, e.g. you're retrieving an element from the end of the result set? I don't know exactly how the result sets are organized, but this behaviour would imply that loading a later element triggers something like loading the earlier elements too. I can't really imagine that. I think the general problem that this is slow lies in the fact that randomly selecting elements means a) you need access to the full list of things b) applying a sort Sorting has a complexity of at least O(n log n) which becomes slow enough for large sets that it's noticable. BTW: How large is large? Christian -- gocept gmbh & co. kg - forsterstraße 29 - 06112 halle/saale - germany www.gocept.com - [EMAIL PROTECTED] - phone +49 345 122 9889 7 - fax +49 345 122 9889 1 - zope and plone consulting and development
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
_______________________________________________ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users