Re: getFolderContents: serious performance problem

Benoit Delbosc <[email protected]>
Newsgroups gmane.comp.web.zope.cps.devel
Message-ID <[email protected]>
Hi

Yves Bastide a écrit :
> Hi,
> 
> CPSDefault.utils.getFolderContents causes a big performance problem on a 
> site
> we installed. A subsection containing about 4000 documents takes some 40
> secondes to display for a 'SectionReader' user, versus 7 seconds for the 
> Manager.
> 
> The profiler points out one main culprit: getRolesInContext (and also
> DateTime's _parse_args). (*)
> 
> My first try was to give the View permission to the Authenticated role 
> in the
> subsection instead of using a SectionReader local role, but there wasn't 
> much
> improvement. After reading CPSDefault.utils.filterContents, the reason 
> is obvious:
> {{{
>         # filter non effective or expired published content
>         if not _checkPermission(ModifyPortalContent, item):
>             review_state = wtool.getInfoFor(item, 'review_state', 
> 'nostate')
>             if review_state == 'published':
>                 doc = item.getContent()
>                 if now < doc.effective() or now > doc.expires():
>                     continue
> }}}
> 
> (_checkPermission could be pushed down in the tests; but I'm not sure 
> whether
> that would be much more efficient. The dates tests may also be costly.)
> 
> After my colleague remarked that searches were much quicker (~ 5 
> seconds, and
> with a more complex display), we tried to force using
> getCatalogFolderContents, and lo! folder_view became 8 times faster.
> 
> So I'd like to know
> 
> * How to systematically use getCatalogFolderContents instead of
> getFolderContents (in a clean way :) ) -- I'm not yet comfortable with CPS
> views' many levels of inclusion
Using the ZMI add a boolean property to the portal named 
'use_catalog_for_folder_contents' with a True value.

> * Why it's not the case already (I've had incomplete indexes, but assume 
> it's
> my fault)
It is a bit slower if you have only few items in a folder.

> * Bonus question: can one sort on several indexes -- i.e. some of my 
> documents
> have a specific field which should be used as a default sort key; how to 
> get
> also documents of other types?
I think you need to replace the default sort on position_in_container 
with 2 sort keys: your new index first then position_in_container.

Regards

ben
_______________________________________________
cps-devel mailing list
http://lists.nuxeo.com/mailman/listinfo/cps-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.