fix(perf): index scores/facts hot queries + cap facts count + reap mongosh zombies #81

Merged
gertjan merged 1 commit from perf/page-load-indexes into main 2026-07-10 10:39:34 +00:00
Owner

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

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>
fix(perf): index scores/facts hot queries + cap facts count + reap mongosh zombies
All checks were successful
Deploy / check (pull_request) Successful in 5m10s
Deploy / deploy (pull_request) Has been skipped
208defd1a4
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>
gertjan deleted branch perf/page-load-indexes 2026-07-10 10:39:34 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
gertjan/bodega!81
No description provided.