How to Make Text Search Fast in Postgres
Description: Your search worked perfectly on a few thousand rows. Then the table hit 15 million — and the same search started taking 8–9 seconds. In this video I show you exactly why that happens, at the disk and memory level, and the one correct index that takes it from ~8s down to 0.4s.
We go deep on how Postgres actually finds your data: why a normal B-tree index can’t help a LIKE '%text%' search, what a trigram is, and how a GIN trigram index (pg_trgm) lets Postgres search inside your text fast. Real app, real 15M-row table, real numbers — no toy examples.
If you’ve ever added an index and watched your search stay slow, this is why.
⏱ Chapters
0:00 — The search that got slow
0:32 — Why it’s slow (disk, RAM & the sequential scan)
1:31 — The normal index: B-tree (and why it fails here)
2:20 — The right index: trigram GIN, explained
3:38 — Building it live: CREATE INDEX CONCURRENTLY
4:23 — The result + when NOT to add an index
🔧 What you’ll learn
Why large tables suddenly make search slow
How disk → RAM → CPU reads cause a sequential scan
B-tree vs trigram GIN — which index your search actually needs
How ILIKE '%...%' text search works under the hood
Building a GIN trigram index without downtime (CONCURRENTLY)
Why indexes aren’t free — the storage & write cost
🌐 Neszen
Website → https://neszen.com
Get your backend reviewed → https://review.neszen.com
#PostgreSQL #Database #Backend
Full hashtag set (YouTube uses the first 3 above the title; keep these in the description for reach):
#PostgreSQL #Database #Backend #DatabaseIndexing #Postgres #SQL #TrigramIndex #GINIndex #BackendDevelopment #WebDevelopment #SoftwareEngineering #Performance #Coding #Developer #Neszen Close description
We go deep on how Postgres actually finds your data: why a normal B-tree index can’t help a LIKE '%text%' search, what a trigram is, and how a GIN trigram index (pg_trgm) lets Postgres search inside your text fast. Real app, real 15M-row table, real numbers — no toy examples.
If you’ve ever added an index and watched your search stay slow, this is why.
⏱ Chapters
0:00 — The search that got slow
0:32 — Why it’s slow (disk, RAM & the sequential scan)
1:31 — The normal index: B-tree (and why it fails here)
2:20 — The right index: trigram GIN, explained
3:38 — Building it live: CREATE INDEX CONCURRENTLY
4:23 — The result + when NOT to add an index
🔧 What you’ll learn
Why large tables suddenly make search slow
How disk → RAM → CPU reads cause a sequential scan
B-tree vs trigram GIN — which index your search actually needs
How ILIKE '%...%' text search works under the hood
Building a GIN trigram index without downtime (CONCURRENTLY)
Why indexes aren’t free — the storage & write cost
🌐 Neszen
Website → https://neszen.com
Get your backend reviewed → https://review.neszen.com
#PostgreSQL #Database #Backend
Full hashtag set (YouTube uses the first 3 above the title; keep these in the description for reach):
#PostgreSQL #Database #Backend #DatabaseIndexing #Postgres #SQL #TrigramIndex #GINIndex #BackendDevelopment #WebDevelopment #SoftwareEngineering #Performance #Coding #Developer #Neszen Close description
