Query Optimizer Deep Dive—Part 1

The SQL Server query optimization pipeline, early stages of compilation, and cardinality estimation. Includes trivial plans.
The SQL Server query optimization pipeline, early stages of compilation, and cardinality estimation. Includes trivial plans.
The important differences between SQL Server aggregates with a GROUP BY
clause (vector) and those without (scalar aggregates).
Dynamic seek plans driven by Constant Scan and Merge Interval operators.
How to force SQL Server to generate a parallel execution plan, including some of the reasons the server sometimes chooses a serial plan.
A SQL Server bug in cardinality estimation with serial partial aggregates. Covers how SQL Server uses local and partial aggregates.
Query rewrites to efficiently perform a DISTINCT
aggregate using other aggregates. The SQL Server 2012 optimizer transformation that performs the rewrite for you.
Finding the statistics used to compile a SQL Server query using undocumented trace flags.
Page splits caused by populating an Index Spool. EXECSYNC
waits when loading a parallel spool.
SQL Server b-tree seeks can use binary search or linear interpolation (with linear regression). The latter can be more efficient, except when key values are separated by a small fixed gap.
SQL Server seeks using a unique index can be much slower than the same index when not marked unique.
SQL Server can perform an equality seek much more quickly when the index used for seeking is marked as UNIQUE
.
The data types, number, and nullability of joined columns can dramatically affect SQL Server row mode hash join performance.
The SQL Server bitmap operator enables early semi join reduction for hash and merge joins.
SQL Server does not allow us to write an ANY
aggregate directly, but there is a way to get the optimizer to produce one using with a filter.
A compact way to write null-aware comparisons in SQL Server using EXISTS
or INTERSECT
.
The internals of parallel row mode query execution in SQL Server.
A SQL Server bug that can cause slow SUM
and AVG
calculations.
Query tuning considerations that are often overlooked. How deep internals knowledge can help you write better T-SQL.