Create Extended Events Session to Capture a Single Stored Procedure

By Greg 1 comment

Do you ever have a stored procedure that you know is performing badly and needs tuning, but you’re struggling to capture when it is run or what parameters were passed in?I had this problem recently, I knew that a particular stored procedure was running slowly for some parameters, but figuring out what the bad combination […]

CTEs are not Staging Tables

By Greg 1 comment

If you have a complex query, a CTE (Common Table Expression) can be a great way to break down the query into individual parts. What is often overlooked by developers is that CTEs can cause significant performance problems when used incorrectly. A common pattern I have seen is joining to a CTE multiple times. This […]

Option Recompile

By Greg No comments

When doing query tuning, sometimes the answer can be that it’s just better to get SQL Server to recompile a plan based on the data passed in. You might have a batch process that runs every hour and sometimes it has only a few hundred rows, other times it has a few billion rows. The […]

Are Stored Procedure Parameters always cached?

By Greg No comments

Does SQL Server always cache your parameters? Does it always keep track of what you pass in?

Using OPTION (RECOMPILE)

By Greg No comments

This week, I was trying to improve the performance of a bit of SQL and noticed that it generated significantly different query plans depending on the parameters passed in. So I tried to work out how to make it run well for all scenarios.