chore(db): tune document autovacuum for connector sync churn - #7962
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
No issues found across 3 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.
Re-trigger cubic
Connector syncs update this table in bursts that outrun autovacuum at the default 20% scale factor, which on a table of this size only triggers once dead rows are already substantial. Sustained bloat stops index-only scans trusting the visibility map, so the knowledge base listing's token aggregate degrades into per-row heap fetches and can exceed its statement timeout. The factors are less aggressive than 0357's on purpose. That one is a small queue table, while this is one of the largest here and shares a small autovacuum worker pool with many other large tables, so triggering too eagerly would risk holding a worker continuously and starving its peers. Cost limit and cost delay are left unset so the table stays inside cross-worker I/O balancing.
waleedlatif1
force-pushed
the
chore/document-autovacuum
branch
from
September 18, 2026 05:48
9bffde0 to
f6c298f
Compare
Contributor
|
Comments describing measured behaviour carried absolute production sizing — index byte sizes, chunk and row totals — which the repo's publishing rules exclude and which a public reader does not need. The measurements that justify each decision stay; only the figures that size production are replaced. The ship scrub missed these because its grep matched identities and IDs but never numbers, and because code and migration comments do not feel like publishing even though they are. It now states the distinction explicitly and greps the diff for byte sizes, k/M-scale entity counts, and seven-figure totals, while deliberately still allowing ordinary engineering numbers.
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.
Summary
documentso connector sync churn triggers cleanup well before the default 20% threshold wouldWhy
Connector syncs update this table in bursts large enough to outrun autovacuum at the default scale factor. Once dead rows accumulate, index-only scans can no longer trust the visibility map, so the knowledge base listing's token aggregate degrades into per-row heap fetches and the request can exceed its statement timeout.
Comparing the same query and the same data before and after autovacuum had caught up — with no change to the query, its indexes, or the schema — showed an order-of-magnitude difference in execution time, driven entirely by how many heap fetches the aggregate had to perform. The bloated case did not complete within the statement timeout.
Why these values, and not 0357's
0357set more aggressive factors onoutbox_event, a small queue table. This is one of the largest tables here and shares a small autovacuum worker pool with many other large tables, so triggering too eagerly would risk holding a worker continuously and starving its peers. These factors still trigger several times earlier than the defaults without monopolising the pool.Per-table storage parameters are the documented mechanism for this. Cost limit and cost delay are deliberately left unset: PostgreSQL excludes tables carrying either from cross-worker I/O balancing, which is not a trade worth making on a table this busy.
What this does not fix
Even fully vacuumed, the listing aggregate scans the table's index entries for the knowledge base on every request and remains slow. That baseline is architectural rather than a maintenance problem and needs its own change.
Type of Change
Testing
bun run check:migrations origin/stagingpasses (backward-compatible). Lint,check:audits(46 audits),docs-manifest:check, andtype-checkpass. Snapshot chain verified:0362.prevId == 0361.idand the snapshot content is identical apart from the id pair, matching how0357recorded a settings-only migration.Checklist