Partial index for claims still awaiting topic tagging

Each enrich.topics batch scanned all claims for untagged ones; after the
history backfill a run took hours and blocked the enrich queue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
simonandClaude Opus 5.5 committed 2026-11-14 12:23:27 +01:00
1 parent d03b9643e9
commit 7bd0142734
1 file changed
+7
@@ -0,0 +1,7 @@
-- enrich.topics fetches the next batch of untagged claims on every iteration; without an index each batch scanned
-- all claims (over a million after the history backfill) and a run took hours, blocking the enrich queue. The
-- predicate must stay identical to the query in enrich/topics.py. Built CONCURRENTLY by hand on 2026-11-14.
CREATE INDEX IF NOT EXISTS claim_untagged_idx ON claim (id)
WHERE claim_type IN ('media_mention', 'statement', 'donation', 'side_job', 'appearance', 'meeting', 'travel',
'money_flow', 'government_decision', 'wiki_edit', 'career')
AND NOT (data ? 'topics_tagged');