Skip to content

perf(Segment Membership): Members list improvements#7924

Merged
khvn26 merged 1 commit into
mainfrom
fix/segment-membership-list-drop-final
Jul 1, 2026
Merged

perf(Segment Membership): Members list improvements#7924
khvn26 merged 1 commit into
mainfrom
fix/segment-membership-list-drop-final

Conversation

@khvn26

@khvn26 khvn26 commented Jul 1, 2026

Copy link
Copy Markdown
Member

Thanks for submitting a PR! Please check the boxes below:

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

Contributes to #7593.

In this PR, we make two changes to the Segment Membership read path:

  1. Drop FINAL in the list query. Adopt a two-stage LIMIT 1 BY identifier dedup and limit trait reads to a page.
  2. Filter is_deleted = false in both read queries. Neither excluded soft-deleted identities before, so deleted identities appeared in the members list and were counted.

How did you test this code?

Added new unit tests.

Verified the queries against production. A 52k-identity environment, default first page (no search term), LIMIT 11, returning 11 rows:

Query shape Warm latency Warm bytes Cold Cold S3 GETs
FINAL (before) 2.7–4.2s ~370 MB 7.3s 6,211
No FINAL 0.12s 22 MB 1.5s 816
Single-stage LIMIT 1 BY 0.13–0.22s 160 MB 1.8s 1,601
Two-stage LIMIT 1 BY (this PR) ~0.10s 43 MB 1.9s 1,602

…dentities

Replace FINAL in the members-list query with a two-stage LIMIT 1 BY
identifier dedup: the inner query resolves the page's identifiers reading
only small columns, the outer materialises the full traits JSON for that
page. FINAL parses the wide traits JSON for the whole environment before
filtering, and that JSON split over many per-path files fans out into
thousands of object-storage GETs on a cold read.

Filter is_deleted = false in both read queries; neither excluded
soft-deleted identities before, so they appeared in the list and counts.

beep boop
Claude-Session: https://claude.ai/code/session_01EgZ5iHpDASZzCapiHRxHLB
@vercel

vercel Bot commented Jul 1, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Jul 1, 2026 10:42am
flagsmith-frontend-preview Building Building Preview, Comment Jul 1, 2026 10:42am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
flagsmith-frontend-staging Ignored Ignored Preview Jul 1, 2026 10:42am

Request Review

@khvn26 khvn26 marked this pull request as ready for review July 1, 2026 10:42
@khvn26 khvn26 requested review from a team as code owners July 1, 2026 10:42
@khvn26 khvn26 requested review from emyller and removed request for a team July 1, 2026 10:42
@github-actions github-actions Bot added api Issue related to the REST API docs Documentation updates labels Jul 1, 2026
@github-actions github-actions Bot added performance and removed docs Documentation updates labels Jul 1, 2026
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-e2e:pr-7924 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api-test:pr-7924 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-frontend:pr-7924 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-7924 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-api:pr-7924 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-7924 Finished ✅ Results

@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.63%. Comparing base (f5b6273) to head (3096474).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7924   +/-   ##
=======================================
  Coverage   98.63%   98.63%           
=======================================
  Files        1497     1497           
  Lines       58989    59013   +24     
=======================================
+ Hits        58183    58207   +24     
  Misses        806      806           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  5 passed

Details

stats  5 tests across 3 suites
duration  34 seconds
commit  3096474
info  🔄 Run: #17990 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  4 passed

Details

stats  4 tests across 3 suites
duration  38.7 seconds
commit  3096474
info  🔄 Run: #17990 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  3 passed

Details

stats  3 tests across 3 suites
duration  46.8 seconds
commit  3096474
info  🔄 Run: #17990 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  4 passed

Details

stats  4 tests across 3 suites
duration  1 minute, 1 second
commit  3096474
info  🔄 Run: #17990 (attempt 1)

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Visual Regression

17 screenshots compared. See report for details.
View full report

@matthewelwell matthewelwell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marking as requested changes, but I'm happy for the change to be a response to my comment for documentation purposes, although ideally I'd like to see an elaboration on the comment.

Comment thread api/segment_membership/services.py
@khvn26 khvn26 merged commit 43c99a2 into main Jul 1, 2026
53 checks passed
@khvn26 khvn26 deleted the fix/segment-membership-list-drop-final branch July 1, 2026 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Issue related to the REST API performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants