[Zope3-Users] getting random results out of a catalogs field index
ct at gocept.com
Sat May 5 12:37:09 EDT 2007
Am Samstag, den 05.05.2007, 17:42 +0200 schrieb Dominique Lederer:
> 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?
gocept gmbh & co. kg - forsterstraße 29 - 06112 halle/saale - germany
www.gocept.com - ct at gocept.com - phone +49 345 122 9889 7 -
fax +49 345 122 9889 1 - zope and plone consulting and development
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://mail.zope.org/pipermail/zope3-users/attachments/20070505/809f2399/attachment.bin
More information about the Zope3-users