282c3b437c
Eliminates full table scans on all text search queries by enabling pg_trgm extension and creating GIN indexes with gin_trgm_ops on every column used in LIKE/ILIKE '%text%' patterns. Changes: - Add pg_trgm extension to schema.sql - Add 10 GIN trigram indexes: contacts (full_name, first_name, last_name, nickname, organization, email::text, phone::text), calendar_events (summary), files (name), folders (name) - Unify all LOWER(col) LIKE patterns to col ILIKE — eliminates .to_lowercase() allocation in Rust and ensures index match - Add minimum 3-char guard on search queries so PostgreSQL uses the trigram index instead of falling back to sequential scan - Add migration 004 with CONCURRENTLY for zero-downtime upgrades Expected improvement: 100-500x faster text searches on large datasets (e.g. 100K contacts: ~1.5s → ~3ms). https://claude.ai/code/session_01QpWV7HXAagdZfyefUw6wKC