Plansplaining, part 9. Recursive CTEs

4 Comments
I had to skip three months, but finally it is here: part eight of the plansplaining series. Each of these posts takes an execution plan with an interesting pattern, and details exactly how that plan works. I am pretty sure that (almost) everyone reading this blog knows that a CTE (Common Table Expression) is an independent subquery that can be named and then referenced (multiple times if needed) in the main query. This makes CTEs an invaluable tool to increase the readability of complex queries. Almost everything we can do with a CTE can equally well be done by using…
Read More

More information in execution plans

1 Comment
Troubleshoorting performance issues can be hard. Having as much information available at our fingertips does not magically make this easier but it does at least save us the burden of having to collect that information from other places. That’s why I like how much extra information Microsoft has been adding to execution plans in recent releases. During this year’s PASS Summit, I went to a session presented by Pedro Lopes and Joe Sack. Pedro explained in his half of the session that Microsoft has the goal of making sure that everything we need for troubleshooting will be available in the…
Read More

T-SQL Tuesday #106: How to use triggers and not be sad

No Comments
The T-SQL Tuesday subject for September, chosen by Steve Jones (b|t), is to write about an experience I had with triggers. I decided to apply a very loose interpretation of his assignment and write more about triggers in general. Undeserved hate My very first SQL Server related job was quite unusual. I was added to a team that developed software using a code generator. We had to define business rules (such as constraints and derivation rules) on top of a conceptual information model for the company. The tool would then generate T-SQL code to support and implement those rules. The…
Read More

The best execution plan book ever written

1 Comment
It all started back in 2012 – yes, six years ago! That was when I was first asked if I wanted to be the technical reviewer for Grant Frtichey’s book on execution plans. I obviously said yes … and then a lot of time passed because first Grant was busy, then we decided to wait for the SQL Server 2014 changes to become clear, and then yet other things intervened. Actual work started just over three years ago. If I had known back then that it would take this long, that I would spend so much time on this book,…
Read More

T-SQL Tuesday #105: Brick walls

1 Comment
It’s the second Tuesday of August already, and that means it’s T-SQL Tuesday time. This month’s topic, chosen by Wayne Sheffield (b|t), is to write about brick walls we ran into and how we dealt with the situation. Thinking about this topic, I remembered two moments in my career where I really was stuck … and then got unstuck in two very different ways. The unconscious solution The first event I want to share took place a long time ago. It was early in my career, my first programming job in fact. My job was to maintain and improve some…
Read More

Plansplaining, part 8. To join the impossible join

This is part eight of the plansplaining series. Each of these posts takes an execution plan with an interesting pattern, and details exactly how that plan works. In this post we look at a query that, given the known limitations of the available join operators, appears to be impossible to execute. But it’s a legal query so it should run. And it does. But how? Sample query The query below can be executed in any version of the AdventureWorks sample database. Don’t bother understanding the logic, there is none. It is merely constructed to show how SQL Server handles what…
Read More

My thoughts on session levels

Almost every conference I go to, either as speaker or as an attendee, indicates the level of sessions. Sometimes this is done with a description (beginner / intermediate / advanced), more often with a number (typically 100 – 200 – 300 – 400 – 500, though I have seen other scales as well). This is obviously a good thing to do. If you are just new in the field, attending a highly advanced session would be a waste of time. And if you have many years of experience then you will probably not learn much from a beginner-level session. But…
Read More

T-SQL Tuesday #104: Make Ola backup BizTalk

In 2009, Adam Machanic (b|t) started the monthly blog event known as T-SQL Tuesday. One person picks a topic, and everyone is invited to blog about it on the second Tuesday of the month. The July 2018 host is Bert Wagner (b|t), and his chosen topic is: Code You Would Hate To Live Without. Talk about a broad topic! I could fill a book on that topic, and the same probably goes for many others. But since my time is limited, I have decided to cherry-pick just two of my favorite scripts. This post is about the second: a small…
Read More

T-SQL Tuesday #104 (part 1): sp_metasearch

In 2009, Adam Machanic (b|t) started the monthly blog event known as T-SQL Tuesday. One person picks a topic, and everyone is invited to blog about it on the second Tuesday of the month. The July 2018 host is Bert Wagner (b|t), and his chosen topic is: Code You Would Hate To Live Without. Talk about a broad topic! I could fill a book on that topic, and the same probably goes for many others. But since my time is limited, I have decided to cherry-pick just two of my favorite scripts. This post is about the first: sp_metasearch. Impact…
Read More

Plansplaining, part 7. The Constant Scan that returns no data

This is part seven of the plansplaining series. Each of these posts takes an execution plan with an interesting pattern, and details exactly how that plan works. In this post we look at a deceptively simple query: a simple SELECT with an ISNULL to show either a row returned or a placeholder value. And yet there is more going on under the covers than one might expect. Sample query The query below can be executed in any version of the AdventureWorks sample database. It returns a code string representing the version number on the 2016 and 2017 versions; on older…
Read More

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close