SQL Server Interview Question #202

What is cardinality estimation?

Advanced Query Optimization Senior Advanced

Detailed Explanation

Cardinality estimation is the process of predicting how many rows each operator in an execution plan will process or return.

These estimates strongly influence index selection, join algorithms, join order, memory grants, and parallelism. If SQL Server estimates 10 rows but actually processes 1,000,000, the chosen plan may be inappropriate.

Statistics, data distribution, predicate relationships, parameter values, and the Cardinality Estimator model all influence these estimates. Comparing Estimated Number of Rows with Actual Number of Rows is therefore an important performance diagnostic.