Skip to content

Excessive calls to enumerateUsers() in the Plone Control Panel #1

Open
auspex opened this Issue Jun 2, 2011 · 1 comment

2 participants

@auspex
auspex commented Jun 2, 2011

Re: http://stackoverflow.com/questions/6047618/using-plone-4-and-pas-plugins-sqlalchemy-with-many-users

When using pas.plugins.sqlalchemy and Plone 4, with many users, user enumeration takes a very long amount of time (O(n)), performing a query and a match for each user present in the database. If the system has thousands of users, searching for a user, changing roles and permissions, are all impossible activities.

The first thing that jumps out is that it gets the Session() before checking the cache, which is sure to create some overhead.

@zedr provided a patch which prevents the problem, but removes new functionality added to PAS in Plone 4.
By applying these changes to /plone/app/controlpanel/usergroups.py the problem is solved:

166c166,169
<         inheritance_enabled_users = searchView.merge(chain(*[searchView.searchUsers(**{field: searchString}) for field in ['login', 'fullname', 'email']]), 'userid')
---
>         import logging; logging.warn('PASSED!!!')
>         import pdb; pdb.set_trace()
>         #inheritance_enabled_users = searchView.merge(chain(*[searchView.searchUsers(**{field: searchString}) for field in ['login', 'fullname', 'email']]), 'userid')
>         inheritance_enabled_users = searchView.merge(chain(*[searchView.searchUsers(**{field: searchString}) for field in ['login']]), 'userid')
184c187,188
<         explicit_users = searchView.merge(chain(*[searchView.searchUsers(**{field: searchString}) for field in ['login', 'fullname', 'email']]), 'userid')
---
>         #explicit_users = searchView.merge(chain(*[searchView.searchUsers(**{field: searchString}) for field in ['login', 'fullname', 'email']]), 'userid')
>         explicit_users = searchView.merge(chain(*[searchView.searchUsers(**{field: searchString}) for field in ['login']]), 'userid')

@zedr also provided a tool to generate users for testing http://pastie.org/1931291

e.g, to create 1000 random users on a MySQL database, run:

./mass_user_add.py mysql://root:secret@localhost/mydb -n 1000
@auspex auspex was assigned Jun 2, 2011
@nutjob4life

See also https://bugs.launchpad.net/ldapuserfolder/+bug/693065 — a similar issue that indicates a flaw in the PAS architecture.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.