Repository navigation
perf(Analytics): Add lookup index for feature evaluation buckets - #9218
IlarionHalushka wants to merge 5 commits into
Conversation
The bucket rollup's `update_or_create` row lock and the pre-insert overlap check both filter on `environment_id`, `bucket_size`, `feature_name` and `created_at`, but only the primary key was indexed, so each lookup scanned the whole table. Add a non-unique B-tree on those columns, created concurrently on PostgreSQL like the existing analytics index migrations. Labels stay a residual filter, since buckets may legitimately differ only by labels.
|
@IlarionHalushka is attempting to deploy a commit to the Flagsmith Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
All reported issues were addressed across 4 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Long multibyte feature names can push the index entry past PostgreSQL's B-tree size limit, failing the rollup for those buckets. Index on environment, bucket size and start time instead; the remaining rows per lookup are one time slot's features.
An interrupted concurrent build leaves an invalid index that IF NOT EXISTS would skip, so drop any leftover before building it.
There was a problem hiding this comment.
0 issues found across 3 files (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Requires human review: Auto-approval skipped because this PR is from an external contributor.
Re-trigger cubic
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9218 +/- ##
==========================================
- Coverage 98.96% 98.10% -0.86%
==========================================
Files 1724 1725 +1
Lines 73823 73911 +88
==========================================
- Hits 73056 72514 -542
- Misses 767 1397 +630 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
khvn26
left a comment
There was a problem hiding this comment.
Thanks for the contribution! Just one comment.
Co-authored-by: Kim Gustyr <[email protected]>
for more information, see https://pre-commit.ci
|
@khvn26 thanks, committed your suggestion. |
There was a problem hiding this comment.
0 issues found across 1 file (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Requires human review: Auto-approval skipped because this PR is from an external contributor.
Re-trigger cubic
Thanks for submitting a PR! Please check the boxes below:
docs/if required so people know about the feature.Changes
Contributes to #9217
The rollup's
update_or_createlock and the overlap check scan the wholeFeatureEvaluationBuckettable. This adds a non-unique index on(environment_id, bucket_size, created_at). Feature names stay out of it, so long names cannot exceed PostgreSQL's index entry size. It is built concurrently on PostgreSQL, so it doesn't lock the table, though it may take a while on large installs.How did you test this code?
New tests against PostgreSQL: the migration creates and drops the index,
EXPLAINon the real lookups uses it, buckets that differ only by labels can still both be created, and the longest multibyte feature name fits.