Our default user listing query at admin/people returns duplicate users. Those users get filtered upon display but we end up with crazy paging. Here is the current query:

SELECT u.uid AS uid, u.name AS name, u.status AS status, u.created AS created, u.access AS access FROM users u LEFT OUTER JOIN users_roles ur ON u.uid = ur.uid WHERE (u.uid <> 1) ORDER BY u.created DESC LIMIT 0, 50

To see the problem, use devel_generate to create 100 users with multiple roles (requires latest devel_generate). Then view admin/people. I recommend changing the limit in user_admin_account() from 50 to 5 so you can quickly see that at times, only 3 or 4 rows are on each page.

We have to be careful how we fix this. In D6 we always add a DISTINCT which murders performance for a site with many users (economist.com has 3M users). We should not join to roles table IMO when no role condition is present. We can user_load_multiple() on each row, IMO. When a role condition is present, we should join on role but still not DISTINCT since only one role can be selected at a time. See #604290: user admin page slow with lots of users for a D6 patch.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

catch’s picture

So getting all the uids, then a user_load_multiple() seems like it'll hopefully fix the paging without murdering the performance. If user_load_multiple() is badly behaved, we still have time to change the internals before release.

JeremyFrench’s picture

Assigned: Unassigned » JeremyFrench

I am working on a patch. Should be ready today.

JeremyFrench’s picture

Assigned: JeremyFrench » Unassigned
Status: Active » Needs review
FileSize
2.59 KB

Here is a first stab at a patch.

JeremyFrench’s picture

FileSize
2.3 KB

There was a tab in the patch. Removed it.

JeremyFrench’s picture

FileSize
2.51 KB

Remove the distinct from the count query in this patch

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

Well done. Note that UserAdminTestCase already keeps us honest. No new testing is needed IMO.

Status: Reviewed & tested by the community » Needs review

Re-test of user_admin.patch from comment #5 was requested by webchick.

Re-test of user_admin.patch from comment #5 was requested by JeremyFrench.

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community
webchick’s picture

Status: Reviewed & tested by the community » Fixed

Thanks! I am not sure why I didn't commit this back when I first read it. Sorry about that.

Committed to HEAD.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.