Заказы конкретного клиента через связь
Заказы конкретного клиента через связь
Отчёт показывает заказы клиента, найденного по имени. Клиент один, заказов у него десяток — а обе таблицы читаются целиком.
Соединение само по себе не проблема — проблема в том, что дороги к заказам клиента нет. Постройте её; индекс по users.name в этой задаче не нужен.
Speed this query up with an index
SELECT o.id, o.status, o.created_at FROM orders o JOIN users u ON u.id = o.user_id WHERE u.name = 'Anna 100'
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 Seq Scan on orders
- the query reads at most 333 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