Repository navigation
perf(db): vacuum and analyze the answers and their citations daily - #1315
Merged
Merged
Conversation
prompt_results and prompt_result_citations only grow, and at the default scale factors autovacuum's insert pass reached them about every three weeks. The reads by brand and window are about the latest days, the pages the visibility map didn't cover yet, so their index-only scans went to the heap, and the planner's statistics stopped before those days. The insert pass now runs at 1% of the rows inserted (about daily on each table) and analyze at 2% of the rows changed. Applied on the hosted DB. Claude-Session: https://claude.ai/code/session_0121amRjX7UFrgmGELAtkc7A
13 tasks done
This was referenced Oct 21, 2026
schema.sql is rebuilt with build-schema.sh after the Content stack's migrations. Claude-Session: https://claude.ai/code/session_0121amRjX7UFrgmGELAtkc7A
This was referenced Oct 21, 2026
gkhngyk
added a commit
that referenced
this pull request
Oct 21, 2026
schema.sql is rebuilt with build-schema.sh after #1315's 00224. Claude-Session: https://claude.ai/code/session_0121amRjX7UFrgmGELAtkc7A
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
prompt_results(578k rows, 3.4 GB) andprompt_result_citations(4.8M rows) only grow. At the default scale factors, autovacuum's insert pass reached them about every three weeks, and analyze ran on the citations about every ten days. As of today they had 78k answers and 784k citations inserted since their last vacuum.The reads by brand and window use
idx_prompt_results_brand_created_coverandprompt_result_citations_brand_created_cover_idx, and they're about the latest days: exactly the pages the visibility map didn't cover yet. Measured during the Content stack reviews:Migration 00224 sets, on both tables:
autovacuum_vacuum_insert_scale_factor = 0.01: the insert pass runs about once a day. It only reads pages that aren't all-visible yet, so each run stays small.autovacuum_analyze_scale_factor = 0.02: about every other day.It's applied on the hosted DB already. The first runs start on their own, since both tables are past the new thresholds.
Related issue
None. Found in the reviews of #1287, #1290, #1292 and #1308.
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
select relname, reloptions from pg_class where relname in ('prompt_results', 'prompt_result_citations');shows both settings.pg_stat_user_tables.last_autovacuumfor both tables is today's. Anexplain (analyze, buffers)of a 30-day read on the cover index then shows few heap fetches.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)No web or server code changes.
schema.sqlis rebuilt withbuild-schema.sh.🤖 Generated with Claude Code
https://claude.ai/code/session_0121amRjX7UFrgmGELAtkc7A