Patch #35324

Preload principal and roles in members#index

Added by Thomas Löber 16 days ago. Updated 10 days ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Performance
Target version:5.0.0

Description

Hi,

MembersController#index should preload the principal and roles of the members.

When this data is not preloaded, iterating over the @members array in app/views/members/index.api.rsb causes a lot of database queries.

A patch is attached.

Thanks,
Thomas

members_index_preload.diff Magnifier (741 Bytes) Thomas Löber, 2021-05-28 12:27

History

#1 Updated by Go MAEDA 11 days ago

  • Target version set to Candidate for next major release

I have confirmed the issue. Before applying the patch, three SQL statements like the following are executed for each member.

  Principal Load (0.1ms)  SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ?  [["id", 9], ["LIMIT", 1]]
  MemberRole Load (0.5ms)  SELECT "member_roles".* FROM "member_roles" WHERE "member_roles"."member_id" = ?  [["member_id", 15]]
  CACHE Role Load (0.0ms)  SELECT "roles".* FROM "roles" WHERE "roles"."id" = ? LIMIT ?  [["id", 2], ["LIMIT", 1]]

Before:

After:

#2 Updated by Go MAEDA 10 days ago

  • Target version changed from Candidate for next major release to 5.0.0

Setting the target version to 5.0.0.

Also available in: Atom PDF