fix(perf): index scores/facts hot queries + cap facts count + reap mongosh zombies #81
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
gertjan/bodega!81
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "perf/page-load-indexes"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Page-load data population was slow (homepage scores ~3s, facts ~5s). Root
cause was two under-indexed Mongo queries hit on every cold cache, not a
missing cache layer — both endpoints were already TTL-cached.
index and stops at LIMIT (docsExamined 25468 -> 50, 261ms -> 2ms).
instead of an exact count over ~450k docs (~1s) just to fill a pagination
total nobody pages through. list_facts news ~2.5s -> ~140ms.
orphans that were piling up as zombies (~6k) and slowing the shell.
Indexes already built on production; indexes.py keeps setup-database in sync.
Co-Authored-By: Claude Fable 5 noreply@anthropic.com
Page-load data population was slow (homepage scores ~3s, facts ~5s). Root cause was two under-indexed Mongo queries hit on every cold cache, not a missing cache layer — both endpoints were already TTL-cached. - scores_snapshot: add {horizon:1, score:-1} so get_top_scores walks the index and stops at LIMIT (docsExamined 25468 -> 50, 261ms -> 2ms). - facts: add {fact_type:1, published_at:-1} for the default news feed. - list_facts: cap count_documents at 10k (COUNT_SCAN stops early, ~30ms) instead of an exact count over ~450k docs (~1s) just to fill a pagination total nobody pages through. list_facts news ~2.5s -> ~140ms. - docker-compose: init:true on mongodb so tini reaps mongosh healthcheck orphans that were piling up as zombies (~6k) and slowing the shell. Indexes already built on production; indexes.py keeps setup-database in sync. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>