SQLBits 2024

Now Where Did THAT Estimate Come From?

This session is a deep dive into cardinality estimation. It starts with the basics, covering statistics, predicates, and correlation. But we then move on to hardly documented advanced topics, such as aligning histograms to estimate the cardinality after a join.
The SQL Server Query Optimizer makes its plan choices based on estimated rowcounts. If those estimates are wrong, the optimizer will very likely produce a poor plan. And there's nothing you can do about it. Or is there?
In this session, you will learn exactly where these estimates come from. You will gain intimate knowledge of how statistics are built and maintained and how they are used to estimate row counts. But you will also learn how filters and joins influence those estimates.
Though the focus of this session is on understanding the cause of bad estimates, you will also learn ways to fix the problems and get better estimates - and hence, better performing queries.