What are statistics in SQL Server, and why do they matter?
Quick Answer
Statistics are histograms and density data describing the distribution of values in a column or index. The optimizer uses them to estimate how many rows a predicate will return (cardinality), which drives every plan choice — seek vs scan, join type, memory grant. Stale or missing statistics cause bad estimates and bad plans.
Statistics are the optimizer's picture of your data — a histogram of value distribution plus density information. When it plans a query it uses them to guess how many rows each step produces, and that estimate decides whether it seeks or scans, which join algorithm it uses, how much memory to grant. If the stats are stale — say a big import happened and auto-update hasn't triggered — the estimates are wrong and you get a plan tuned for the wrong row counts. A common one is the ascending-key problem where queries for today's data estimate one row because the new values aren't in the histogram yet.
- Auto-created on filtered/join columns; auto-updated when roughly 20% of rows change (lower dynamic threshold on large tables in newer versions).
- The “ascending key” problem: recent rows (today's orders) fall outside the histogram until stats refresh — mitigated by trace flag 2371 / newer CE, or manual updates.
UPDATE STATISTICS ... WITH FULLSCANfor accuracy; sampled updates are faster but less precise.- Rebuilding an index updates its stats with fullscan; reorganising does not.