SQL Server keeps statistics per statistics object. Creating an index also creates a statistics object for its key columns, and if a column used in a condition has no statistics, the optimizer automatically creates single-column statistics (_WA_Sys_…). A statistics object consists of a header, a density vector for combinations of the leading key columns, and a histogram (up to 200 steps) on the first column. The optimizer estimates the row count of each operator from these values and the rules of the cardinality estimator (CE).
Summary
Item
Description
When created
Index creation (same as a full scan), automatic creation (AUTO_CREATE_STATISTICS), CREATE STATISTICS
Update
Automatic update (AUTO_UPDATE_STATISTICS), UPDATE STATISTICS, sp_updatestats, index rebuild
Automatic update threshold
Compatibility 130 and above: when changed rows exceed MIN(500 + 0.2 × row count, √(1000 × row count)). 129 and below: 500 + 20%
Update timing
At the next compilation that uses the statistics after the threshold is exceeded. With AUTO_UPDATE_STATISTICS_ASYNC, this compilation uses the old statistics and the update runs in the background
Sample
Automatic update uses an automatic sample based on table size. WITH FULLSCAN, SAMPLE n PERCENT, PERSIST_SAMPLE_PERCENT = ON
Histogram
Only on the first column of a statistics object, up to 200 steps
Freezing
NORECOMPUTE (excluded from automatic update)
Sandbox
Gathered with FULLSCAN after loading, and the database's automatic creation and automatic update are turned off (compatibility level 160)
Reading a Statistics Object
DBCC SHOW_STATISTICS ('orders', 'orders_x1') WITH STAT_HEADER, DENSITY_VECTOR;
SELECT * FROM sys.dm_db_stats_histogram(OBJECT_ID('customers'),
(SELECT stats_id FROM sys.stats WHERE object_id = OBJECT_ID('customers') AND name = 'customers_x1'));
SELECT s.name, sp.rows, sp.rows_sampled, sp.steps, sp.modification_counter, sp.last_updated
FROM sys.stats s CROSS APPLY sys.dm_db_stats_properties(s.object_id, s.stats_id) sp
WHERE s.object_id = OBJECT_ID('orders');
Header
Value
Sandbox value of orders_x1
Meaning
Rows / Rows Sampled
2,000,000 / 2,000,000
The sample is the whole table (FULLSCAN)
Steps
21
Number of histogram steps
Updated
2026-11-26 13:38
Last update
modification_counter
0
Number of rows changed since the update (compared with the automatic update threshold)
Density Vector
All density
Columns
0.0000099999997
cust_id
0.0000005
cust_id, ord_dt
0.0000005
cust_id, ord_dt, ord_id
Density is 1 ÷ number of distinct values. For cust_id it is 1 ÷ 100,000. If the value of an equality condition is unknown at compile time (a local variable, OPTIMIZE FOR UNKNOWN, an outer value inside an NL join), the estimate is row count × density, an average of 20 rows per customer. Only the densities of leading combinations exist, so the density of (cust_id, ord_dt) is usable, but this object has no density for ord_dt alone.
Histogram
In the histogram of customers_x1(grade), the three values each become a step as they are.
RANGE_HI_KEY
EQ_ROWS
RANGE_ROWS
DISTINCT_RANGE_ROWS
GOLD
9,000
0
0
NORMAL
90,000
0
0
VIP
1,000
0
0
Column
Meaning
RANGE_HI_KEY
Upper boundary value of the step
EQ_ROWS
Number of rows equal to the boundary value
RANGE_ROWS
Number of rows between the previous step's boundary value and this boundary value (both ends excluded)
DISTINCT_RANGE_ROWS
Number of distinct values in that range
AVG_RANGE_ROWS
RANGE_ROWS ÷ DISTINCT_RANGE_ROWS. The estimated number of rows per value in the range
grade = 'VIP' equals a boundary value, so the estimate uses EQ_ROWS, 1,000, as it is. Oracle in the sandbox, which has no histogram, sees the same condition as 33,333 customers (Oracle Optimizer Statistics). orders_x1 has 2 million rows but only 21 steps. This is because SQL Server merges similar ranges to reduce steps, and customers between steps are estimated with AVG_RANGE_ROWS (the range average).
Cardinality Estimator
Item
Old estimator (CE 70)
New estimator (CE 120 and above, 2014+)
AND conditions
Product of selectivities (independent)
Exponential backoff: most selective condition × square root of the second × fourth root of the third …
Joins
Aligns the histograms of both sides step by step
By default aligns only the minimum and maximum of the histograms (Coarse Alignment)
Values outside the histogram range (recent dates)
Estimated as 1 row
Estimated from density (mitigates the ascending key problem)
How to select
Compatibility level 110 and below, USE HINT('FORCE_LEGACY_CARDINALITY_ESTIMATION')
Compatibility level 120 and above
The new estimator is not always better. For an AND condition on uncorrelated columns, the old estimator's product is more accurate, and for strongly correlated columns the new estimator is more accurate. Check which one was used with CardinalityEstimationModelVersion in the plan.
How to Change Statistics
-- Update by reading everything
UPDATE STATISTICS dbo.orders orders_x1 WITH FULLSCAN;
-- Set the sample percentage, and later automatic updates use the same percentage
UPDATE STATISTICS dbo.orders WITH SAMPLE 10 PERCENT, PERSIST_SAMPLE_PERCENT = ON;
-- Multi-column statistics (first-column histogram + combination density)
CREATE STATISTICS st_orders_status_dt ON dbo.orders (status, ord_dt) WITH FULLSCAN;
-- Filtered statistics: distribution of only some rows
CREATE STATISTICS st_orders_canceled_dt ON dbo.orders (ord_dt) WHERE status = 'CANCELED' WITH FULLSCAN;
Situation
Method
The sample is small and the histogram is coarse
FULLSCAN or PERSIST_SAMPLE_PERCENT
Recent values are outside the histogram
Update right after loading. Use the new estimator
A skewed value is a problem only under some conditions
Filtered statistics
The best plan differs per parameter value
OPTION (RECOMPILE), OPTIMIZE FOR, Parameter Sensitive Plan (PSP) in 2022
Plans fluctuate because of updates
NORECOMPUTE, force the plan with Query Store
Comparison with Other DBMSs
Item
SQL Server
Oracle
PostgreSQL
Unit
Statistics object (index or column combination)
Table, column, index
Table, column
Distribution
First-column histogram of up to 200 steps
Only on skewed columns used in conditions (SIZE AUTO)
NOTE
The automatic update threshold and estimator behavior differ by compatibility level and version. The values in this document were verified on SQL Server 2022 (compatibility level 160) in the sandbox.