Lesson 22 — Indexes & EXPLAIN (expert)
EXPLAIN QUERY PLAN: see what the database does
EXPLAIN QUERY PLAN before a SELECT shows how SQLite will run it instead of running it. "SCAN" means it reads every row; "SEARCH ... USING INDEX name" means it jumps straight to matches with that index. Checking the plan before and after adding an index proves the index is actually used.
EXPLAIN QUERY PLAN SELECT * FROM orders WHERE customer_id = 7
The last column of each plan row is a readable description.
Why it matters: "why is this page slow?" is usually answered by reading a query plan, not by guessing.
Write the CREATE INDEX on orders(customer_id) named idx_orders_customer. The second plan should then use it.
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
A quick 3-question quiz on this lesson — instant feedback.
Ready for more? Optional paid resources that pick up where this lesson leaves off.
Some links on this page are affiliate links: we may earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases.
Project-based Databases & SQL courses if you want a structured paid path after the free lessons. Wait for a sale — prices drop often.
Browse on Udemy →Search Amazon for Databases & SQL books — check the publication year so the examples match current versions.
Search Amazon →