Understanding Statistics in SQL Server
summary
Explains how SQL Server uses column and index statistics to drive cardinality estimates, shows DBCC SHOW_STATISTICS output (header, density vector, histogram) and matches estimates to actual row counts in demos, and demonstrates that skewed distributions and sampling cause large plan differences: examples include a 5,295 correct estimate, a 5,437 near-miss, and queries returning 22k vs estimated 5k rows. Covers auto-create/update behavior, auto update statistics asynchronously, effects of updates on plan cache and parameter sniffing / parameter sensitivity, and using DBCC SHOW_STATISTICS to decide fixes.
AI-written summary · about
chapters (6)
- 0:00Start
- 4:23Statistics-related Database Options
- 7:02Query or join on a column, get a statistic!
- 25:33How do we manage statistics?
- 26:28Updating statistics
- 29:30Threshold Comparison
related talks
53mThe Most Important Performance Factor in SQL Server and Azure SQL
53mThe Most Important Performance Factor in SQL Server and Azure SQL
52mA Deep Dive into Postgres Statistics
53mSQL Server Internals: The Practical Angle
04mEnhancing Planner Estimates with Extended Statistics in PostgreSQL
42mMariaDB and MySQL — What Statistics the Optimizer Uses
49mSQL Server Query Execution: Expectation vs Reality
53mIndexing Internals for Developers & DBAs
