Repository navigation
perf: bound filtered item-list totals (WI-1910) - #422
Merged
Merged
Conversation
The filtered, collection, QL and search list paths ran COUNT(*) over the full filter join set with no LIMIT, so the aggregate scanned every matching row on each request while the page query beside it stayed index-bounded. Wrap the filter scan in a LIMIT of 10000. Results below the cap stay exact; results at the cap report the cap. The UI already refuses to paginate past 10,000 items (Pagination.svelte maxItems), so the bound matches the existing contract. The unfiltered single-workspace count stays exact and cached. On SQLite with 200k matching rows the count drops from 87.9ms to 2.6ms.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the P1-2 finding in
docs/backend-performance-scaling-review.md.Problem
buildItemListPagePlanonly setworkspaceCountIDfor the unfiltered single-workspace list. Every other list — filters, collections, QL, search, multi-workspace — ranCOUNT(*)over the full 8-join filter set with noLIMIT, so the aggregate scanned every matching row on each request while the page query beside it stayed index-bounded.Change
Wrap the filter scan in a
LIMIT:NewPaginationMetais unchanged. The UI already refuses to paginate past 10,000 items and labels the total "(limited to 10,000)" (Pagination.sveltemaxItems, passed byWorkItemListFooter.svelte), so the bound matches the contract the client already assumes.Evidence
SQLite, 200,000 matching rows:
The
LIMITis inside the subquery, so the engine stops after the cap.Tests
Windshiftapp/core-tests-internal#22 — exact below cap, capped above cap, and page selection beyond the cap. The capped-total assertion fails against the pre-fix code.