Skip to content

⚡ Bolt: Wrap-Up discovery probes each title's first earlier play through the title indexes - #371

Merged
Randomname653 merged 1 commit into
mainfrom
bolt/discovery-index
Nov 28, 2026
Merged

Randomname653 merged 1 commit into
mainfrom
bolt/discovery-index

Conversation

@Randomname653

Copy link
Copy Markdown
Owner

Problem

wrapup_facts._discovery ("Scout vs Loyalist") asks which of the period's top titles were played before the period. It used SELECT DISTINCT coalesce(series_title, title) ... WHERE coalesce(...) IN (top titles): the same index-defeating shape #360 fixed in _comebacks, plus a DISTINCT over every earlier play of regular artists.
Measured on a seeded DB (384k music plays, 20k film plays, ANALYZE, 3000 artists with Pareto-skewed play counts), median of 3: 0.60 s for week and 0.63 s for month (all scope), 0.59 s for music week.

Change

One .first() probe per title (at most ~80), with the predicate spelled series_title = k OR (series_title IS NULL AND title = k) so the title indexes serve it and each probe stops at the first hit. Same semantics: a title counts as known if any earlier play of the member exists (no a_play filter, same as before).

Measured effect / proof

scope / period before after
all / week 0.599 s 0.045 s
all / month 0.630 s 0.041 s
music / week 0.587 s 0.029 s
music / month 0.600 s 0.042 s

The OR-only rewrite (a single IN query with DISTINCT) reached only 0.27 s, so probing is used. Outputs were identical in all four cases.

Tests

tests/test_wrapup_discovery_index.py: checks the film, series, artist and series_title-shadows-title cases, and pins the plan (index SEARCH, no SCAN) of the probe. Without the change it fails ("one first-hit probe per title"); with it, 4/4 pass.
python tests/run_all.py: 357/358 green; the one failure is the known sandbox-only test_enrichment_status_perf.py (SQLite plan, fails identically on untouched main, passes in CI).

Risk & edge cases

Duplicate check

Searched my journal, the other personas' journals, PRs for "discovery"/"wrapup", and git log -300: #360 and #368 touch _comebacks only; _discovery is untouched on main.


Generated by Claude Code

@Randomname653 Randomname653 mentioned this pull request Nov 28, 2026
@Randomname653
Randomname653 merged commit 1a05513 into main Nov 28, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants