Repository navigation
DirsHKDistnPeople: keep today's distribution for the day, warm it (WEBBSITE-47) - #132
Merged
Merged
Conversation
WEBBSITE-47: the default (today) view of the directorships-per-person distribution ran its whole-market query on every request; ~0.5 s with a warm buffer cache (production plan: ~155k shared-buffer hits, plan sound), it hit the 8 s statement timeout once when cold, while every other route in the same minutes was under 220 ms. Today's result is now precomputed per data version and day (_today_or_live, as FDirsPerListcoHKdstn does since WEBBSITE-46) and in the warm list; other dates stay live. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Sentry: WEBBSITE-47 (statement timeout, dbpub_statistics.dirs_hk_distn_people, 1 event 2026-11-25T01:00Z, default URL with no
d).Cause. Not the box: in 00:55–01:05Z every other route's DB spans were under 220 ms p95. The route's 30-day DB p50 is ~330 ms, and the production plan (
scripts/pgq.py --explain) is sound: 520 ms, ~155k shared-buffer hits, nested-loop index scans over directorships/people. Cold, those hits become random reads and the query crossed the 8 s default. Same pattern as WEBBSITE-46 (FDirsPerListcoHKdstn).Fix. Today's distribution (the default view) goes through
_today_or_live, so it is computed once per data version and day, and the page is added towebbsite/warm.pyso a deploy rewarms it. Other dates stay live. Rows are copied before the cumulative columns are added so the cached result is not mutated.Evidence. New check in
tests/test_sentry_regressions.py(item 18): a repeat request for today's page makes no queries. Before the fix:DirsHKDistnPeople today: a repeat is served from the cache: got [None], want []. After: the CI DB-free unit list passes, 198 passed; ruff clean;test_render_parity.pyunchanged.🤖 Generated with Claude Code