-
Notifications
You must be signed in to change notification settings - Fork 726
fix: optimizations for query members #3721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
1 similar comment
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
| ORDER BY | ||
| msa."activityCount" ${direction} NULLS LAST | ||
| LIMIT ${prefetchLimit} | ||
| ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefetch excludes filtered members with low activity counts
The top_msa CTE prefetches members by activity count without applying any filters, then top_members applies filters to this subset. If a user searches or filters for members who have low activity counts, those members won't be in the prefetched set and will be incorrectly excluded from results. The previous logic applied filters before limiting, ensuring all matching members were considered. This can cause queries to return incomplete or missing results when filter criteria don't correlate with activity count.
Note
Performance-focused query refactor with safer joins and better prefiltering.
displayNamefilter uselower(m."displayName")for case-insensitive matchingbuildActivityCountOptimizedQuery:top_msaprefetches by activity,top_membersapplies filters/joinsprefetchLimit,totalNeeded)member_searchandmemberSegmentsAggjoins only when needed for filteringmsain the outer SELECT only if requested byfields; orders bytm."activityCount"Written by Cursor Bugbot for commit a31edb5. This will update automatically on new commits. Configure here.