Avoid expensive sorts when possible.
Section: Covering and ordering
Support ORDER BY with an index
sql
sql
SELECT id, created_at
FROM orders
WHERE status = 'paid'
ORDER BY created_at DESC
LIMIT 50;Explanation
An index on `(status, created_at DESC)` may let the planner filter and return rows in the needed order.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Covering and ordering