Problem
Paginated queries timing out. Team had exhausted index tuning โ every optimization lever was maxed. Root issue: join happened before pagination. Materializing millions of rows, then limiting to 100, is cardinality inversion.
Solution
Reverse operation order: LIMIT from primary table first, then join only for those 100 rows. Changed cardinality from millions-in-join to 100-in-join.
Result
Response time: 3+ minutes โ under 500ms (360x faster). Key insight: separates query tuning from query architecture.