Saturday Night SQL Virtual Group is an open forum for discussions about Business Intelligence and Databases. This chapter sets the stage for every Microsoft SQL Server professional to share knowledge, to learn new techniques, to get answers on various topics related to data technologies, and to resolve real world issues.

Getting Better Query Plans by Improving SQL's Estimates

Sun, Sep 09 2018 01:00 UTC

Getting Better Query Plans by Improving SQL's Estimates

You've been writing T-SQL queries for a few years now, and when you have performance issues, you've been updating stats and using OPTION (RECOMPILE). It's served you well, but every now and then, you hit a problem you can't solve. Your data's been growing larger, your queries are taking longer to run, and you're starting to wonder: how can I start getting better query plans? The secret is often comparing the query plan's estimated number of rows to actual number of rows. If they're different, it's up to you – not the SQL Server engine – to figure out why the guesses are wrong. To improve 'em, you can change your T-SQL, the way the data's structured and stored, or how SQL Server thinks about the data. This session won't fix every query – but it'll give you a starting point to understand what you're looking at, and where to go next as you learn about the Cardinality Estimator.


Brent Ozar

Brent Ozar loves to make SQL Server faster and more reliable. He created sp_Blitz and the SQL Server First Responder Kit. He loves sharing knowledge at BrentOzar.com.

Back to Top
cage-aids
cage-aids
cage-aids
cage-aids