-
Notifications
You must be signed in to change notification settings - Fork 92
Bound the cycle, not just the index, in pg_index_bloat (#2617) #2618
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
Merged
+88
−2
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Oops, something went wrong.
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.
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.
The work budget is deterministic and largest-first with no rotation across cycles:
size_rankis recomputed fromindex_bytes DESCevery run, so an index that lands at rank 201+ today will land there again tomorrow (index sizes don't reorder that fast). For any database with more candidate btree indexes than the budget, everything past rank 200 is not merely "not measured this cycle" as the message says — it is never measured, permanently, until enough of the top 200 shrink or get dropped.That compounds with the reader/UI, which this PR doesn't touch but whose assumptions this collector now breaks:
DarlingPgIndexBloatReader.PgIndexBloatSqlsorts(skipped_reason IS NOT NULL) DESCfirst — written when skip was the rare over-20GB-ceiling case, so surfacing it first made sense ("skipped indexes sort to the top, not out of sight").ViewerServerTab.Postgres.cscalls it withPgGridRowLimit = 200— the exact same number asBudgetLiteral.So on any database with more than ~400 qualifying btree indexes, every skipped row (i.e. every index below rank 200, always the same ones) sorts ahead of every measured row, and the 200-row grid limit is entirely consumed by "not measured this cycle" placeholders. The actually-measured bloat data for the top 200 largest indexes — the whole point of this collector — never appears in the UI at all for those databases, and the smaller/mid-sized indexes where bloat is easiest to miss are permanently invisible too.
Worth considering a rotating or sampled budget (e.g. offset by collection cycle, or a random sample from beyond the top N) so coverage eventually reaches every index, and/or fixing the
skipped_reasonwording so it doesn't promise something ("this cycle") the current implementation can't deliver.