ContentsThe library

What the Planner Decides

The City Already Told You the Postcode

Last timeWhen the Guess Is Wrong

The 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.

The last lesson said that errors multiply up a plan. This one is about the

single most common source of the error at the bottom, which is two filters on

columns that are not telling the database two different things.

The rule being applied

A table with two filters is estimated by multiplying their shares. Nothing more

sophisticated happens, because nothing in the summary of a table records any

relationship between two of its columns: the summary has a histogram per column

and no notion that two columns might be about the same thing.

FIG 1The assumed estimate and the true one
the hat marks the estimate, and the whole of this lesson is about the distance between it and the quantity on the right
the assumed combination: the table size times the share passing the first filter times the share passing the second, as though the two filters were unconnected
the truth, where c is the share of the rows that already passed the first filter which also pass the second, a different quantity entirely from b
The two expressions differ in one symbol. The assumption is that the second share is the same whether or not the first filter has been applied, which is the definition of independence. When the columns are related, the conditional share is larger, often by a great deal, and the estimate is low by exactly the ratio between them.

It is worth being clear that the rule is not a mistake. For two genuinely

unrelated columns, the shares multiply exactly, and most pairs of columns in

most tables are unrelated enough for it to be fine. The trouble is that the

related pairs are also the pairs people filter on together.

The lesson stops here

4 more paragraphs to go

You have read the opening. The rest of the argument, the problems that check whether it landed, and the lines worth keeping at the end all come with a plan.

The first lesson of every course in the library reads the whole way through, free, so you can see exactly what the rest of them are.

See the planThe contents

This is the reading half

Starting the course gives you your own copy of it. Every idea on every page has problems standing under it, marked with a reason rather than a tick, and any sentence you do not believe can be opened and argued with. None of that can happen on a page nobody owns.

The contents

The rest of this course

  1. 01You Asked For Rows, Not For a Method
  2. 02One of Them Is Quadratic and Sometimes It Is the Right Answeropening only
  3. 03It Has Never Looked at Your Dataopening only
  4. 04A Factor of Ten at the Bottom Is a Factor of a Thousand at the Topopening only
  5. 05The City Already Told You the Postcodeyou are here
  6. 06Six Tables Have Seven Hundred Twenty Orders and They Are Not Alikeopening only
  7. 07Find the Lowest Line Where the Two Numbers Stop Agreeingopening only
  8. 08Four Remedies and the One Cause Each of Them Repairsopening only

Read alongside