Sitemap

Forget LIKE Queries — These 3 Postgres Tricks (Trigram, Covering Indexes, GIN) Cut I/O by 70%

A fast path for search and filters that stops wasting buffers and fixes the wrong scans

4 min readOct 14, 2025

--

Press enter or click to view image in full size

Your slow path is not the CPU; it is pages dragged off disk by lazy filters. The moment traffic grows, simple LIKE clauses start full-table walks and drown your cache.

I trim those wasted reads with three moves that turn scattered scans into tight index probes.

The numbers look small per query, then fall hard at scale. If your dashboards spike on text search and JSON filters, this is where the drop starts.

LIKE filters waste I/O you can avoid

A wildcard seems harmless until it forces the planner to read rows it never returns. That is the quiet cost: pages touched, buffers dirtied, cache pressure everywhere.

I replace broad LIKE with indexable patterns or route the search to an index that understands similarity. Once the plan stops scanning blindly, your buffer hits climb and your latency curve flattens.

+------------------------------+
| naive text filter |
| query → Seq Scan → rows |
| ^ |
| LIKE '%term%' |…

--

--

Responses (1)