Ticket #5520 (closed Bug: fixed)

Opened 6 years ago

Last modified 5 years ago

Performance problem with portlet_recent

Reported by: sandland Owned by: optilude
Priority: major Milestone: 2.1.4
Component: Navigation/Folder listings Keywords: portlet_recent performance
Cc:

Description

My plone instance has more than 50,000 cataloged items (mostly PloneExFile's). With that many items, UI performance really drags. After doing a performance analysis, I found that the "portlet_recent" portlet is mostly to blame. It is doing a catalog search which returns *all* items in the catalog, then sorts them by date. A large part of the time gets spent just deserializing DateTime objects in order to do the sort. Here's the code from portlet_recent that is to blame:

results python:request.get('items',

here.portal_catalog.searchResults(sort_on='modified',

portal_type=typesToShow, sort_order='reverse')[:5]);

I've got to think there is a better way to implement this portlet, especially since zope keeps an "undo" history.

Martin Aspeli suggested changing the code to:

results python:request.get('items',

here.portal_catalog.searchResults(sort_on='modified',

portal_type=typesToShow, sort_order='reverse', sort_limit=5)[:5]);

I tried this, and performance was fine, but the most recent list was showing different items than those shown in the list output by the original code.

Change History

comment:1 Changed 6 years ago by sandland

Looks like trac did some funny formatting to my code. Here are the two code samples from above, formatted a little better:

results python:request.get('items',
    here.portal_catalog.searchResults(sort_on='modified',
                                      portal_type=typesToShow,
                                      sort_order='reverse')[:5]);
results python:request.get('items',
    here.portal_catalog.searchResults(sort_on='modified',
                                      portal_type=typesToShow,
                                      sort_order='reverse',
                                      sort_limit=5)[:5]);

comment:2 Changed 6 years ago by alecm

  • Status changed from new to closed
  • Resolution set to fixed

(In [9916]) Add sort_limit parameter to portlet_recent query, fixes #5520

comment:3 Changed 6 years ago by sirgarr

  • Status changed from closed to reopened
  • Resolution fixed deleted

The original poster said that the change in code changed which items displayed in the portlet, however. Is that true?

comment:4 Changed 6 years ago by alecm

  • Status changed from reopened to closed
  • Resolution set to fixed

It almost certainly is not true. If there is some circumstance in which adding "sort_limit=5" to the query changes the result set, then this is a Zope/ZCatalog bug and not an issue for the Plone tracker. Adding sort_limit is the proper fix for this bug, if it has undesirable side-effects, then they should be reported separately, preferably in a more appropriate tracker.

comment:5 Changed 5 years ago by hannosch

  • Milestone changed from 2.1.x to 2.1.4
Note: See TracTickets for help on using tickets.