Orofold Labs

Launching soon

Notes Get in touch

Engineering 3 min read Updated

In-app search: SQL, full-text or search engine?

In short

Product and admin search does not start with a separate search cluster. Match the search backend to catalogue size, typo tolerance, faceting and sync complexity.

Every product eventually needs a search box—for orders in an admin panel, articles on a help centre, or products in an online shop. Teams often jump straight from slow LIKE '%term%' SQL queries to standing up a separate search cluster, adding an entire indexing pipeline before they need it. Choosing the simplest search architecture that meets your real latency and ranking needs saves months of sync bugs.

Three tiers of in-app search compared

ApproachBest fitSync complexityLimitations
Indexed SQL prefix / exact matchSKUs, order IDs, emails, small tables under a few thousand rowsZero (single source of truth)No relevance ranking, weak multi-word matching; %term% scans every row
Database full-text (PostgreSQL / SQLite FTS5)Catalogues, notes, B2B workspaces up to hundreds of thousands of rowsZero or automatic triggers inside the same DB transactionLimited typo tolerance without trigram indexes; heavy dynamic facet counts need care
External search engineLarge multi-attribute e-commerce catalogues, typo tolerance, weighted synonyms, fast faceted countsHigh: async outbox/queue sync, schema mapping, full reindex jobsSecond stateful service to host, back up, secure and monitor

Why SQL LIKE breaks first—and how far database full-text goes

A leading wildcard such as WHERE title LIKE '%cable%' cannot use a standard B-tree index (Database indexes). On 500 rows nobody notices; on 200,000 rows every keystroke in a live search box triggers a full table scan and stalls the database.

Built-in full-text search solves that problem without adding another server. PostgreSQL’s Full Text Search tokenises text into lexemes (with GIN indexes and optional pg_trgm for substring/typo matching), while SQLite’s FTS5 extension provides fast BM25-ranked full-text queries inside the same file. Both keep search results immediately consistent with writes because updates happen in the same database transaction.

When an external search engine earns its cost

Move to a dedicated search engine only when real user queries hit clear limits of relational full-text:

  • Heavy faceting with dynamic counts: e-commerce filters showing live item counts across dozens of attributes simultaneously (see Pagination and facets).
  • Typo tolerance and domain synonyms: users searching misspelled brand names or Czech/Slovak/English variants where rigid exact-stem matching returns zero results.
  • Scale and isolation: multi-million document indices where heavy search aggregations would steal CPU and memory from checkout or transactional database writes.

Search UI details that matter as much as the backend

Fast search feels broken if the browser freezes while typing. To protect responsiveness (Interaction to Next Paint (INP)):

  1. Debounce live-suggest requests (for example 200–300 ms) and abort superseded in-flight fetch() calls with AbortController.
  2. Keep a minimum query length (2–3 characters) before running wildcard or prefix suggestions.
  3. Support exact-identifier shortcuts (order number, SKU, EAN) so staff and repeat buyers jump straight to the exact record.
  4. Always enforce tenant and permission filters inside the search query itself—never filter unauthorised rows only in the UI.

If you adopt an external search engine, build a repeatable full-reindex command from day one. Index drift between the database and search service is inevitable after deploys or partial queue failures.

Sources and limits

Slow product search or broken filters hurting conversion? Share the catalogue structure through our enquiry form.

Common questions

Why does SQL LIKE '%term%' slow down as tables grow?
A leading wildcard prevents a standard B-tree index from narrowing the scan, forcing the database to read every row and check substrings sequentially.
When is built-in database full-text search enough?
PostgreSQL full-text search or SQLite FTS5 handles tens or hundreds of thousands of documents cleanly with zero sync lag, transactional consistency and language stemming when you do not need heavy cross-facet analytics or complex typo ranking.
What is the hidden operational cost of an external search engine?
Every create, update and delete must stay synchronised between your primary database and the search index, requiring retry queues, periodic full reindexing and tenant permission filtering on search queries.

Sources

  1. Full Text Search, PostgreSQL Documentation. Accessed 24 November 2026
  2. SQLite FTS5 Extension, SQLite Documentation. Accessed 24 November 2026
  3. Interaction to Next Paint (INP), web.dev (Google). Accessed 24 November 2026

Further reading

Have an idea that should exist? Or a working product that needs more customers, a new website or a complete rework? Bring us anything. Apply with your idea

All notes