| 1 |
|
| 2 |
|
| 3 |
CREATE EXTENSION IF NOT EXISTS pg_trgm; |
| 4 |
|
| 5 |
|
| 6 |
CREATE INDEX idx_threads_title_trgm ON threads USING GIN (title gin_trgm_ops); |
| 7 |
CREATE INDEX idx_posts_body_trgm ON posts USING GIN (body_markdown gin_trgm_ops); |
| 8 |
|
| 9 |
|
| 10 |
ALTER TABLE threads ADD COLUMN search_tsv tsvector |
| 11 |
GENERATED ALWAYS AS (to_tsvector('english', title)) STORED; |
| 12 |
ALTER TABLE posts ADD COLUMN search_tsv tsvector |
| 13 |
GENERATED ALWAYS AS (to_tsvector('english', body_markdown)) STORED; |
| 14 |
|
| 15 |
CREATE INDEX idx_threads_search_tsv ON threads USING GIN (search_tsv); |
| 16 |
CREATE INDEX idx_posts_search_tsv ON posts USING GIN (search_tsv); |
| 17 |
|