Skip to content

Conversation

@ulemons
Copy link
Contributor

@ulemons ulemons commented Dec 30, 2025

Note

Performance-focused query refactor with safer joins and better prefiltering.

  • Make displayName filter use lower(m."displayName") for case-insensitive matching
  • Rework activity-count optimization in buildActivityCountOptimizedQuery:
    • New two-stage CTEs: top_msa prefetches by activity, top_members applies filters/joins
    • Adds prefetch/oversampling limits to cap work (prefetchLimit, totalNeeded)
    • Applies member_search and memberSegmentsAgg joins only when needed for filtering
    • Keeps msa in the outer SELECT only if requested by fields; orders by tm."activityCount"

Written by Cursor Bugbot for commit a31edb5. This will update automatically on new commits. Configure here.

@ulemons ulemons self-assigned this Dec 30, 2025
@ulemons ulemons added the Bug Created by Linear-GitHub Sync label Dec 30, 2025
@ulemons ulemons marked this pull request as ready for review December 31, 2025 10:34
@github-actions
Copy link
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

1 similar comment
@github-actions
Copy link
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

@github-actions
Copy link
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

ORDER BY
msa."activityCount" ${direction} NULLS LAST
LIMIT ${prefetchLimit}
),
Copy link

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.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Created by Linear-GitHub Sync

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants