Skip to content

[schemas] Text search trigram index for ILIKE fallback#206

Merged
justfinethanku merged 5 commits into
NateBJones-Projects:mainfrom
alanshurafa:contrib/alanshurafa/text-search-trgm
Jun 1, 2026
Merged

[schemas] Text search trigram index for ILIKE fallback#206
justfinethanku merged 5 commits into
NateBJones-Projects:mainfrom
alanshurafa:contrib/alanshurafa/text-search-trgm

Conversation

@alanshurafa

Copy link
Copy Markdown
Collaborator

What this adds

schemas/text-search-trgm/ — installs `pg_trgm` + creates a trigram GIN index on `public.thoughts.content` so `search_thoughts_text` ILIKE fallback queries drop from ~8s to ~150ms.

Perf impact

Query Before After
Rare-word ILIKE fallback ~8s (seq scan) ~100-150ms (bitmap index scan)
Common-word tsvector hit unchanged unchanged

Prerequisites

Install-time

`ANALYZE public.thoughts;` is an explicit post-migration step (Step 4) — planner needs refreshed stats to pick the index immediately.

Review history

Iteratively refined across 3 rounds. Final Codex + Claude reviews clean.

See `schemas/text-search-trgm/README.md`.

@github-actions github-actions Bot added the schema Contribution: database extension label Apr 19, 2026
@alanshurafa alanshurafa added area: schemas Review area: schemas/primitives/data model risk: schema Touches database schema, migration, or data model behavior review: ready-for-maintainer Community reviewer recommends maintainer review alan-reviewed Reviewed by Alan Shurafa in Community Reviewer role labels May 20, 2026
@alanshurafa

Copy link
Copy Markdown
Collaborator Author

Mergeable, no conflicts against main. No blockers from my side; ready whenever it reaches the queue.

@justfinethanku justfinethanku left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maintainer review: Alan's triage says this is mergeable with no blockers and ready for queue. I updated the branch against main, added the repo community badge/creator credit convention, ran markdownlint locally, and GitHub label/lint checks are passing.

@justfinethanku justfinethanku merged commit 70f26e5 into NateBJones-Projects:main Jun 1, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

alan-reviewed Reviewed by Alan Shurafa in Community Reviewer role area: schemas Review area: schemas/primitives/data model review: ready-for-maintainer Community reviewer recommends maintainer review risk: schema Touches database schema, migration, or data model behavior schema Contribution: database extension

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants