The library

Where the data lives

Read a query plan as the decision it is, well enough to say why the database chose that join, where its estimate went wrong, and which of the available fixes addresses the actual cause

What the Planner Decides

Between your query and the rows is a program that chose how to get them. This course covers what it is choosing between, how it guesses the cost, why the guess goes wrong, and how to read the plan it produces.

8 lessons, written and corrected before you arrived. Reading them here needs no account. The first reads the whole way through; the others open and then stop, because a page nobody owns cannot tell who is reading it. Starting the course gives you your own copy, where every idea has problems standing under it and you can ask about any sentence.

Start reading

  1. 01You Asked For Rows, Not For a MethodA query names the answer and says nothing about how to get it. Everything left unsaid is decided by a program you did not write, in a few milliseconds, on every request.
  2. 02One of Them Is Quadratic and Sometimes It Is the Right Answeropening onlyThere are three ways to combine two sets of rows. Their costs can be derived in a paragraph each, and the derivation tells you exactly when each one wins.
  3. 03It Has Never Looked at Your Dataopening onlyEvery decision in a plan rests on how many rows each step will produce. The planner works that out from a few hundred numbers gathered hours ago, and here is exactly how.
  4. 04A Factor of Ten at the Bottom Is a Factor of a Thousand at the Topopening onlyEstimation errors do not stay where they are made. Each join multiplies the errors of its inputs, so a small mistake low in a plan becomes a catastrophic one higher up.
  5. 05The City Already Told You the Postcodeopening onlyThe planner multiplies the shares of two filters as though neither says anything about the other. When the columns are related, that single assumption is where most bad plans begin.
  6. 06Six Tables Have Seven Hundred Twenty Orders and They Are Not Alikeopening onlyWhich tables are joined first decides how many rows every later step carries. The orders cannot all be tried, so they are built up in pieces and reused.
  7. 07Find the Lowest Line Where the Two Numbers Stop Agreeingopening onlyA plan with estimated and actual counts side by side tells you exactly where the reasoning broke. There is one place to look and everything above it is a symptom.
  8. 08Four Remedies and the One Cause Each of Them Repairsopening onlyEvery fix for a bad plan addresses a particular cause. Matching them wrongly is how teams end up with forced plans that stop working when the data moves.