Four Remedies and the One Cause Each of Them Repairs
Last timeReading the Plan It Gives You
Every 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.
The previous lesson ends with a line of the plan and a cause. This one matches
each cause to the remedy that actually repairs it, which matters because the
four remedies are not interchangeable and the convenient one is last.
Refreshing the numbers
The cheapest remedy and the most over-prescribed. A refresh resamples the table
and rewrites the summary: row counts, frequent values, histograms, distinct
counts.
It repairs exactly one cause, which is that the data changed after the summary
was taken. That is a real and common cause, particularly on a table that was
recently loaded, recently grown by an order of magnitude, or had a new value
introduced that the frequent-values list has never seen.
It repairs nothing else, and this is where teams waste time. If the summary was
gathered an hour ago and the estimate on a filtered scan is still out by a
factor of eight hundred, the cause is not staleness, and refreshing again will
produce the same number. Check the gathering time first and only then decide
whether this remedy is even eligible.
Giving it more to work with
The second remedy supplies a number the planner was previously guessing. Which
number depends on what broke, and the previous lesson told you which.
The lesson stops here
5 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 contentsThis 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