-- 007_page_search_index.sql — make page search index-backed and literal. -- -- The page list searched title/content with an unescaped ILIKE pattern: "%" -- and "_" behaved as wildcards and every request scanned the owner's pages. -- The handler now escapes those characters; these trigram indexes let -- Postgres serve the substring predicate without a sequential scan. -- pg_trgm is a trusted extension, so the database owner can enable it. CREATE EXTENSION IF NOT EXISTS pg_trgm; CREATE INDEX IF NOT EXISTS "Page_title_trgm_idx" ON "Page" USING gin (title gin_trgm_ops); CREATE INDEX IF NOT EXISTS "Page_content_trgm_idx" ON "Page" USING gin (content gin_trgm_ops);