The admin panel's main screen shows twenty fresh orders. To hand back twenty rows, the machine sorts a hundred and fifty thousand.
There is no filter here at all — only an order. An index can hand out an order ready-made: it is stored sorted.
Make sure no Sort node is left in the plan.
SELECT * FROM orders ORDER BY created_at LIMIT 20
You may only change the schema: indexes and ANALYZE. The query stays as the task wrote it — no need to send it back.
Grading runs on a larger dataset than the samples show — the answer has to hold at scale.
Sign in to see submission history
Sign inSign in to use AI Mentor
Sign in