-- 031_entity_trigram_index.up.sql
-- Add GIN trigram indexes on entities.slug and entities.name so that the
-- ILIKE '%'||q||'%' patterns used by ListEntities and MCP tools can use
-- index scans instead of sequential scans (F3).

CREATE EXTENSION IF NOT EXISTS pg_trgm;

CREATE INDEX IF NOT EXISTS idx_entities_slug_trgm ON entities USING GIN (slug gin_trgm_ops);
CREATE INDEX IF NOT EXISTS idx_entities_name_trgm ON entities USING GIN (name gin_trgm_ops);