Category: Execution Plans

Performance Tuning

Optional Parameters and Missing Index Requests

That's when it all gets blown away
At one point or another in everyone's SQL-querying career, they end up writing a query that goes something like this:
[crayon-6a6e7b25376ab555108681/]
These are often called optional parameters, and if you spend any time looking at queries, this will make you shudder for many reasons. Poor cardinality estimates, full scans, etc.

Read more about Optional Parameters and Missing Index Requests 11 comments — Join the discussion
Performance Tuning

Indexing for Windowing Functions: WHERE vs. OVER

Life Is Messy
Demo queries have this nasty habit of being clean. Even using a pit of despair like Adventure Works or World Wide Importers, it's easy to craft demo queries that fit the scenario you need to make yourself look like a genius. Stack Overflow, in all its simplicity, makes this even easier (lucky me!) because there's nothing all that woogy or wonky to dance around.

Read more about Indexing for Windowing Functions: WHERE vs. OVER 19 comments — Join the discussion
Performance Tuning

How Much Can One Row Change A Query Plan? Part 1

Last week, Erik showed two queries that were aaaaalmost identical, with only one extra column - and the execution plans were dramatically different. Adding just one eensy column made all the difference in the world.

Now, check out these two queries - the first asks for top 100, and the second asks for top 101:
[crayon-6a6e7b2541892209189693/]
They produce estimated plans that seem identical (PasteThePlan), even down to the estimated costs - note that they're both 50%:

Read more about How Much Can One Row Change A Query Plan? Part 1 13 comments — Join the discussion
Performance Tuning

ColumnStore Indexes: Rowgroup Elimination and Parameter Sniffing In Stored Procedures

Yazoo
Over on his blog, fellow Query Plan aficionado Joe Obbish has a Great Post, Brent® about query patterns that qualify for Rowgroup Elimination. This is really important to performance! It allows scans to skip over stuff it doesn't need, like skipping over the dialog in, uh... movies with really good fight scenes.

Car chases?

Read more about ColumnStore Indexes: Rowgroup Elimination and Parameter Sniffing In Stored Procedures 5 comments — Join the discussion
Performance Tuning

Five Mistakes Performance Tuners Make

There's no Top in the title

And that's because a TOP without an ORDER BY is non-deterministic, and you'll get yelled at on the internet for doing that. This is just a short collection of things that I've done in the past, and still find people doing today when troubleshooting performance. Sure, this list could be a lot longer, but I only have the attention span to blog.

Read more about Five Mistakes Performance Tuners Make 9 comments — Join the discussion
Performance Tuning

SQL 2016 SP1 Shows You Wait Stats in Execution Plans. Or Does It? [UPDATED]

SQL Server 2016 Service Pack 1 brought us performance tuners all kinds of shiny goodies - like the ability to see wait stats inside a query's actual execution plan. I was really excited when this first came out, but I keep seeing some real oddities. Let's keep this one really simple: I'm using the Stack…

Read more about SQL 2016 SP1 Shows You Wait Stats in Execution Plans. Or Does It? [UPDATED] 16 comments — Join the discussion
Performance Tuning

Breaking: SQL Server 2016 SP1 CU2 Supports ENABLE_PARALLEL_PLAN_PREFERENCE Hint

Hot Diggety!
After reading an excellent tip by Dmitry Pilugin about the new hint for forcing a parallel plan in SQL Server 2017, I figured I'd test it out on SQL Server 2016's latest CU to see if it had been back ported yet.

Good news! It has. Obviously. That's the title of the blog post.
Puddin'
Here are the test queries I ran.
[crayon-6a6e7b2547cfd653563670/]
And here are the boring results!

Read more about Breaking: SQL Server 2016 SP1 CU2 Supports ENABLE_PARALLEL_PLAN_PREFERENCE Hint 7 comments — Join the discussion