enrich.embed looks up claims without a chunk on every batch. The existing unique index is on COALESCE expressions, which that lookup can't use, so after the history backfill each run took hours and starved the other enrichers on the same queue. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7 lines
582 B
SQL
7 lines
582 B
SQL
-- enrich.embed looks up claims and documents without a chunk on every batch. chunk_uniq is an expression index
|
|
-- (COALESCE(...)), which those lookups can't use, so each batch scanned the whole table: after the history
|
|
-- backfill (over a million claims) a run took hours and blocked the other enrichers. Built CONCURRENTLY by hand on
|
|
-- 2026-11-14; IF NOT EXISTS makes this a no-op there.
|
|
CREATE INDEX IF NOT EXISTS chunk_claim_idx ON chunk (claim_id) WHERE claim_id IS NOT NULL;
|
|
CREATE INDEX IF NOT EXISTS chunk_document_idx ON chunk (document_id) WHERE document_id IS NOT NULL;
|