Tutorial1 min readPublished Sep 3, 2026
Postgres full-text search is enough until it isn't. Here is where the line is.
We put off adding a dedicated search service for two years. A tutorial on getting real search out of Postgres, and the signals that told us to move on.
A client asked us to add search to their product. Everyone's instinct was to reach for a dedicated search service immediately. We used Postgres's built-in full-text search instead, and it held up for two years and roughly 4 million documents before we finally needed to move.
The setup that got us surprisingly far
ALTER TABLE documents ADD COLUMN search_vector tsvector
GENERATED ALWAYS AS (to_tsvector('english', title || ' ' || body)) STORED;
CREATE INDEX documents_search_idx ON documents USING GIN (search_vector);A generated column plus a GIN index gets you ranked, typo-tolerant-ish, full-text search with zero additional infrastructure, no data synchronization to maintain, and search results that are always exactly as fresh as the row they came from.
Where it started to strain
Query latency crept past 200ms once the table passed roughly 4 million rows with our index and hardware.
Fuzzy matching for typos required bolting on
pg_trgm, which works but is noticeably less capable than a purpose-built engine.Faceted search — filtering by category and search term together — got expensive to express and to keep fast as filter combinations multiplied.
The signal we actually used to decide it was time
Not a specific row count or latency number, but the fact that we were writing increasingly elaborate SQL to work around limitations a dedicated search engine solves natively. That complexity, more than any single metric, was the tell.
If your search needs are simple — search a handful of text fields, rank by relevance, filter by one or two fields — Postgres will very likely take you further than you expect. Move to a dedicated engine when you notice yourself fighting the tool, not before.
Continue exploring
The three-hour deploy that taught us to fear big-bang migrations
A database migration that should have taken twenty minutes, what actually went wrong, and the rollback plan that saved us.
The Ultimate Guide to Discord Bots
Discord bots have revolutionized the way communities interact and engage with each other on the popular communication platform, Discord.
What we check before recommending Kubernetes to a client
A short checklist we run before every infrastructure proposal, because the honest answer is often 'not yet.'
Explore this topic
Backend
Related experts
Sebastian Terri
Making Complex Technology Easier to Understand
1 article
Bogdan Dan
It doesn't matter how many times you fall, the important thing is not to break the bottle!
Getronics
1 article
Related businesses
Nodesin
Software · Budapest, Hungary
Cloud Workflow Automation with AI Agents
1 article
