-- Trigram-backed fuzzy search on mangas. The `%` operator becomes -- index-supported once gin_trgm_ops is in place, so the search query -- can mix substring matches (ILIKE) with fuzzy matches (similarity > -- pg_trgm.similarity_threshold, default 0.3) without a full scan. CREATE EXTENSION IF NOT EXISTS pg_trgm; CREATE INDEX mangas_title_trgm_idx ON mangas USING gin (title gin_trgm_ops); -- Author is nullable; index only the rows that have one so the index -- stays tight. CREATE INDEX mangas_author_trgm_idx ON mangas USING gin (author gin_trgm_ops) WHERE author IS NOT NULL;