hard20 pts · first answer countsindexingquery-tuning
LIMIT 1 takes minutes
The query below takes minutes. EXPLAIN shows an Index Scan on orders_pkey with a Filter on merchant_id. merchant_id = 991 has only 3 orders, all very old. Why is this plan slow?
SELECT * FROM orders WHERE merchant_id = 991 ORDER BY id DESC LIMIT 1;
Discussion 0
Join free to post in the discussion.
Related questions
- When a B-tree index helpsDatabase Administrator
- Finding slow MySQL queriesDatabase Administrator
- Index on a yes/no columnDatabase Administrator
- How InnoDB stores table rowsDatabase Administrator
- What an InnoDB secondary index points toDatabase Administrator
- LIKE with a leading %Database Administrator
- What a hash index supportsDatabase Administrator
- Cost of extra indexes on insertsDatabase Administrator