Execution Strategies and Runtime Behavior

Joins, parallel execution, memory grants, spills, and adaptive execution.

93 associated posts89 primary posts

T-SQL & Development

Using WITH (NOEXPAND) to Get Parallelism with Scalar UDFs in Indexed Views

Scalar functions are the butt of everybody's jokes: their costs are wrong, their STATS IO results are wrong, they stop parallelism when they're in check constraints, their stats are wrong in 2017 CU3, they stop parallelism in index rebuilds and CHECKDB, I could go on and on.

Recently, we ran across yet another scenario where scalar UDFs were killing performance.

Read more about Using WITH (NOEXPAND) to Get Parallelism with Scalar UDFs in Indexed Views 7 comments — Join the discussion
Performance Tuning

Memory Grants: SQL Server’s Other Public Toilet

Sharing Is Caring
When everything is going well, and queries are behaving responsibly, one need hardly think about memory grants.

The problem becomes itself when queries start to over and under estimate their practical needs.
Second Hand Emotion
Queries ask for memory to do stuff. Memory is a shared resource.

Read more about Memory Grants: SQL Server’s Other Public Toilet 13 comments — Join the discussion

Froid: How SQL Server 2019 Will Fix the Scalar Functions Problem

Scalar functions and multi-statement table-valued functions are notorious performance killers. They hide in execution plans, their cost is under-estimated, the row estimates are way off, they cause queries to go single-threaded, I could go on and on.

Microsoft is bringing a fix in SQL Server 2019, and thanks to a newly published paper, we know more about how they're doing it. Folks from Microsoft and the Gray Systems Lab wrote Froid: Optimization of Imperative Programs in a Relational Database (17-page PDF, and slightly easier-to-digest 12-page PDF).

Read more about Froid: How SQL Server 2019 Will Fix the Scalar Functions Problem 8 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
T-SQL & Development

Other People’s Blog Posts I Talk About the Most

In my work with clients and classes, some blog posts come up a LOT.

Forcing a Parallel Query Execution Plan by Paul White - Paul's posts usually cover execution plan components in incredible detail, but the real gem in this one is the section called "Parallelism-Inhibiting Components." If your T-SQL includes this stuff, the whole plan or a zone of it will go single-threaded.

Read more about Other People’s Blog Posts I Talk About the Most 5 comments — Join the discussion

Anatomy Of An Adaptive Join

I don't like it unless it's brand new
When new features drop, not everyone has time to jump on top of them and start looking at stuff. That's what consultants with nothing better to do are for.

I've been excited about this feature since talking to The Honorable Joseph Q. Sack, Esq. about it at PASS last October. My pupils dilated like I just found the bottom of a bottle of Laphroaig 18.

Read more about Anatomy Of An Adaptive Join 4 comments — Join the discussion
T-SQL & Development

Hold The FiIter: Startup Expression Predicates

Long distance information
There was a rather interesting question posted on dba.stackexchange.com recently about CASE expression order of execution with an OR predicate. Mouthful, I know! When I saw it, I got all "I HAVE A REALLY GOOD ANSWER" and started to write demo queries.

Then I wrote this blog post instead. Sorry, j.r. -- you see, I hit an actual execution plan bug that did not bode well.

Read more about Hold The FiIter: Startup Expression Predicates 6 comments — Join the discussion