← back to Restaurant Directory

db/migrations/002_enrichment_index.sql

18 lines

-- Partial index on facility_enrichment.enriched_at IS NULL — enables fast
-- "what still needs enrichment" lookups during the 37K-record cuisine run.
-- Without this the resume/idempotency check seq-scans every batch.

CREATE INDEX IF NOT EXISTS idx_facility_enrichment_pending
  ON facility_enrichment (facility_id)
  WHERE enriched_at IS NULL;

-- Also index by source so we can break out "qwen-classified" from
-- "manually corrected" later.
CREATE INDEX IF NOT EXISTS idx_facility_enrichment_source
  ON facility_enrichment (source);

-- Cuisine itself is searchable — partial index on non-null cuisines.
CREATE INDEX IF NOT EXISTS idx_facility_enrichment_cuisine
  ON facility_enrichment (lower(cuisine))
  WHERE cuisine IS NOT NULL;