- Problem
- the original search was a substring scan over three fields - sequential scans that couldn't keep up with as-you-type queries from power users and vendors.
- Approach
- a unified /catalog/search endpoint backed by pg_trgm GIN trigram indexes, a small power-search query language (multi-term AND, quoted exact match, -exclusion, card-number and type facets), and an index-backed fuzzy fallback that only fires when the exact pass is thin.
- Result
- fuzzy matches return in ~29 ms (verified with EXPLAIN ANALYZE) over 185k+ live cards, with the endpoint rate-limited to 120 req/min.