Learning on Web Dev Open is free for all.

ArcadeQuery Planner
Arcade

Query Planner

Phase 05 · Backend EngineeringPlayable

Add the indexes that turn a collection scan into a bounded lookup.

0 / 6 cleared
orders10.0M rows · 200k pages
columndistinctnote
id10.0M
user_id2.0M
status4paid, pending, shipped, refunded
created_at9.0M
total40k
The query
SELECT *
FROM orders
WHERE user_id = 4471
Level 1

Find one customer’s orders without reading the table.

target ≤ 40 pages · at most 1 index

Indexes
  • none: the planner has only the table
EXPLAIN
Seq Scan on orders
  • rows examined · 10.0M
  • pages read · 200k (target 40)
  • write cost · 1 row + 0 index updates

No index covers this query, so every page is read.

Write user_id, created_at or the whole CREATE INDEX ON orders (user_id, created_at); both parse. Fifty rows to a page and a four-level tree are this planner’s simplifications; the ordering rules it applies are the real ones.