Лента последних заказов
Лента последних заказов
Главный экран админки показывает двадцать свежих заказов. Чтобы отдать двадцать строк, машина сортирует сто пятьдесят тысяч.
Фильтра здесь нет вовсе — есть только порядок. Индекс умеет отдавать порядок готовым: он и хранится отсортированным.
Сделайте так, чтобы узла Sort в плане не осталось.
Speed this query up with an index
SELECT * FROM orders ORDER BY created_at LIMIT 20
Apenas CREATE/ALTER/DROP — não é preciso um SELECT no final.
What counts as solved
You may only change the schema: indexes and ANALYZE. The query stays as the task wrote it — no need to send it back.
- the plan has no Sort
- the plan has no Seq Scan on orders
- the query reads at most 12 8 KB pages
Grading runs on a larger dataset than the samples show — the answer has to hold at scale.
Entre para ver seu histórico de envios
EntrarEntre para usar o AI Mentor
EntrarFocus radio
Paused · SomaFM · Fluid