sojorn/go-backend/internal/database/migrations/20260204000001_search_optimization.up.sql

14 lines
576 B
SQL

-- Enable pg_trgm extension
CREATE EXTENSION IF NOT EXISTS pg_trgm;
-- Create GIN indices for profiles
CREATE INDEX IF NOT EXISTS idx_profiles_handle_trgm ON profiles USING gin (handle gin_trgm_ops);
CREATE INDEX IF NOT EXISTS idx_profiles_display_name_trgm ON profiles USING gin (display_name gin_trgm_ops);
-- Create GIN index for post body
CREATE INDEX IF NOT EXISTS idx_posts_body_trgm ON posts USING gin (body gin_trgm_ops);
-- Create GIN index for post tags
-- Assuming tags is a text[] column
CREATE INDEX IF NOT EXISTS idx_posts_tags_gin ON posts USING gin (tags);