Patch #16905

Count users with a single query on group list

Added by Jérôme BATAILLE over 3 years ago. Updated 9 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:Code cleanup/refactoring
Target version:2.6.0

Description

All users are loaded for each group, only to count them !

RM_16905_groups_index_users_count_optim.diff Magnifier (981 Bytes) Jérôme BATAILLE, 2014-05-16 16:17

Associated revisions

Revision 13149
Added by Jean-Philippe Lang over 3 years ago

Count users with a single query on group list (#16905).

History

#2 Updated by Jean-Philippe Lang over 3 years ago

  • Subject changed from Admin : groups otpimization of users count to Count users with a single query on group list
  • Category changed from Groups to Code cleanup/refactoring
  • Status changed from New to Resolved
  • Assignee set to Jean-Philippe Lang
  • Target version set to 2.6.0

This patch didn't work for me, as the hash keys are strings (tested with postgresql):

irb(main):001:0> User.joins(:groups).group('group_id').count
=> {"98913"=>2}

Fix committed in r13149 with test.

#3 Updated by Jérôme BATAILLE over 3 years ago

Jean-Philippe, thanks to have reviewed this patch.

#4 Updated by Jean-Philippe Lang over 3 years ago

  • Status changed from Resolved to Closed

#5 Updated by Jérôme BATAILLE 10 months ago

Hi, you can indicate in the Resolution that's it's Fixed, if you have the time to, thanks a lot.

#6 Updated by Toshi MARUYAMA 9 months ago

Jérôme BATAILLE wrote:

Hi, you can indicate in the Resolution that's it's Fixed, if you have the time to, thanks a lot.

"patch" tracker does not have "resolution" filed.

Also available in: Atom PDF