Skip to content
Go back

The query that scans twelve million orders

Read an execution plan and add one composite index that matches the production query's filter and sort.

The order history endpoint exceeds its SLO after data growth. Database CPU is high, but only one query dominates the slow log.

Inspect the execution plan on the read replica before proposing an index.

Try: mysql -e 'EXPLAIN ANALYZE SELECT * FROM orders WHERE tenant_id=42 ORDER BY created_at DESC LIMIT 50;'