What this sprint implements
- tsvector columns with GIN indexes on search-critical tables
- ts_query search with relevance ranking replacing LIKE queries
- Text search dictionaries for stemming and stop word handling
Your search feature uses WHERE name LIKE '%keyword%' which scans every row in the table. It is tolerable today, and it gets slower with every row you add.
For teams whose search feature uses LIKE queries that scan every row and slow down linearly as data grows. LIKE is not a search engine. It is a string matching operator that scans every row.
WHERE name LIKE '%keyword%' with a leading wildcard cannot use a B-tree index. PostgreSQL reads every row. On a small table that is tolerable. On a big one it takes seconds. The growth is linear and inevitable.
LIKE returns all matching rows with no ranking. A product named 'Wireless Keyboard' and a review mentioning 'keyboard' are treated equally. Users get irrelevant results because there is no concept of match quality.
LIKE '%run%' matches 'running' but not 'ran.' It does not handle typos, plurals, or word variations. tsvector's 'english' dictionary stems words to their root, so 'swimming lessons' and 'swim lesson' resolve to the same lexemes and match. LIKE has no concept of this, so users lose relevant content to exact-match limitations.
Best fit when your search is slow or returning poor results and you want to fix it without adding Elasticsearch.
LIKE works until it does not.
We implement tsvector search with ranking, fuzzy matching, and autocomplete, all within PostgreSQL.
Map all search queries in the application. Measure current performance. Identify which tables need tsvector columns. Configure text search dictionaries for your content language.
Add tsvector columns and GIN indexes. Rewrite queries to use websearch_to_tsquery with ts_rank for relevance ordering, so real user input maps cleanly to a ranked bitmap index scan instead of a sequential scan. Proof release target: search under 15ms with ranked results.
Add pg_trgm for fuzzy matching and typo tolerance. Implement search suggestions with trigram similarity. Add search result highlighting.
Search performance monitoring. Query analytics for common searches. Handoff with search operations guide and index maintenance schedule.
Fast, relevant, fuzzy-tolerant search, all within PostgreSQL with no external services.
We implement search in the database you already have.
PostgreSQL's full-text search handles most application search needs, even on large tables. A GIN-indexed tsvector turns search into a bitmap index scan whose cost scales with the number of matches, not the size of the table. Add ts_rank for relevance and pg_trgm for fuzzy matching and you get most of what Elasticsearch offers without running a second system.
Full scans Scanned on every search query
From full table scans to a 15ms target.
Fixed scope, fixed price.
PostgreSQL full-text search handles most use cases with proper indexing, even on large tables. Beyond that, or if you need complex faceted search, multi-language search across the same index, or real-time indexing of a heavy document stream, Elasticsearch becomes worth the operational cost.
Yes. Supabase runs standard PostgreSQL with pgvector and pg_trgm available. We add the tsvector as a generated column so it stays in sync automatically, build a GIN index on it, and expose a search function using websearch_to_tsquery and ts_rank. That function is called via supabase.rpc() from the client, so search syntax with quotes and negation works the way users expect.
tsvector columns make rows in text-heavy tables bigger, and the GIN index takes extra space on top. We measure the added storage on your table before you commit. For search that has to stay fast, the trade-off is usually worth it.
We use the pg_trgm extension, which breaks text into three-character trigrams and scores how many two strings share. With a gin_trgm_ops index and a tuned similarity threshold, a search for 'recieve' still finds 'receive' and 'Jonathon' still finds 'Jonathan.' Combined with tsvector for ranked results, you get a search experience that feels like Google without an external search engine.
Yes. We build a suggestion index from your most common search terms and high-value content titles. As the user types, trigram matching returns ranked suggestions almost instantly. The suggestions update automatically as your content changes. No manual curation needed.
For search over a single table we use a generated column, so PostgreSQL recomputes the tsvector automatically on every insert and update with no trigger to maintain. When search has to pull text from related tables, generated columns cannot reference them, so we use a trigger instead. Either way the rebuild is automatic and adds very little to each write. Your application code never manages search indexing. It happens transparently at the database level.
ByKostadin StambolievFounder and Imaginator
Published Updated