Skip to content

[OP-20529] Remove redundant visibility check and load principals directly - #26317

Merged
ulferts merged 1 commit into
devfrom
perf/optimize-members-widget-follow-up
Oct 26, 2026
Merged

ulferts merged 1 commit into
devfrom
perf/optimize-members-widget-follow-up

Conversation

@tisba

@tisba tisba commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up for #26209

Ticket

https://community.openproject.org/wp/OP-20529

What are you trying to accomplish?

I actually missed a piece of feedback in #26209 (comment) about avoiding a redundant check, if the user can view members. While mentioning this to @ulferts we realized that we also can avoid loading Member instances altogether since we want to have Principal instances ultimately.

What approach did you choose and why?

Load Principal directly and by that skipping also the extra membership visibility check. #members_by_role already does an explicit check in the very beginning (introduced in #26209).

The resulting query, executed once per role looks like this now:

SELECT "users"."id", "users"."login", "users"."firstname", "users"."lastname", "users"."mail", "users"."admin", "users"."status", "users"."last_login_on", "users"."language", "users"."ldap_auth_source_id", "users"."created_at", "users"."updated_at", "users"."type", "users"."first_login", "users"."force_password_change", "users"."failed_login_count", "users"."last_failed_login_on", "users"."consented_at", "users"."webauthn_id"
FROM "users"
INNER JOIN "members" ON "users"."id" = "members"."user_id"
INNER JOIN "members" "members_users" ON "members_users"."user_id" = "users"."id"
INNER JOIN "member_roles" ON "member_roles"."member_id" = "members_users"."id"
LEFT OUTER JOIN "users" "principals_members" ON "principals_members"."status" != $1 AND "principals_members"."id" = "members"."user_id"
WHERE "members"."project_id" = $2 AND "users"."status" != $3 AND "users"."type" NOT IN ($4, $5, $6, $7) AND "users"."status" != $8 AND "member_roles"."role_id" = $9
ORDER BY "members"."created_at" DESC
LIMIT $10

AI involvement

None

Merge checklist

  • Added/updated tests
  • Added/updated documentation in Lookbook (patterns, previews, etc)
  • Tested major browsers (Chrome, Firefox, Edge, ...)

@tisba
tisba requested a review from ulferts October 26, 2026 10:50
@github-actions github-actions Bot added the ai: None/Assisted 👤 No AI assistance used OR only snippets. A human effectively wrote and understands all the code. label Oct 26, 2026
@ulferts
ulferts merged commit 9810269 into dev Oct 26, 2026
18 checks passed
@ulferts
ulferts deleted the perf/optimize-members-widget-follow-up branch October 26, 2026 12:38
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

ai: None/Assisted 👤 No AI assistance used OR only snippets. A human effectively wrote and understands all the code. performance

Development

Successfully merging this pull request may close these issues.

2 participants