A query that returns instantly on a hundred rows can crawl on a hundred million. This module explains why, and what to do about it. You'll start with indexes — the sorted lookup structures, usually B-trees, that let a database find rows without scanning the whole table — including when to add one and the cost they carry for writes.
You'll then learn to read execution plans with EXPLAIN to see exactly how the database runs a query, spot full table scans, and verify that an index is actually being used. From there you'll pick up practical query tuning techniques: selecting only the columns you need, writing filters that can use indexes, and avoiding common patterns that slow queries down.
Work through the lessons in order, then continue on to Views, Procedures & Triggers.
An introduction to what a database index is and why it makes lookups dramatically faster.
A practical demonstration of creating an index and seeing a slow query become fast.
Covers how indexes work and how to choose which columns to index.
A visual explanation of how a database turns a query into a plan, and how to read the steps it chooses.
A deeper look at interpreting EXPLAIN output to find where a query is spending its time.
A rundown of practical techniques for making slow queries faster once you've found the bottleneck.