Search that survived a hundredfold catalogue
Kestrel Trade
Rebuilt listing search and filtering as the catalogue grew from forty thousand items to four million.
The problem
Search was a set of LIKE queries against the listings table. At three hundred thousand rows the median query passed four seconds and the database spent most of its time on sequential scans.
What we did
- Measured the real query mix instead of the assumed one — 80% of traffic hit five filter shapes
- Moved those shapes to a denormalised read model updated by change events
- Added cursor pagination so deep pages stopped re-scanning from the start
- Kept the old path behind a flag until the new one matched it on a replayed week of traffic
What changed
Median search latency fell below two hundred milliseconds and stayed there through a hundredfold catalogue increase.
- TypeScript
- PostgreSQL
- Redis
- Next.js
