Using standard DMV’s, it is difficult to get execution plans or query text from programs using cursors. You typically see an OPEN CURSOR statement, or a FETCH statement. This makes it difficult to identify what query was being run and what plan was being used. Query store actually tracks performance of both of these separately. […]
Read MoreUsing GO in SSMS versus not – what is the difference
You might see GO used in SQL text. The GO command marks the end of a batch. As a result, any statements executed after this are part of a new batch. This also means any context of the previous batch is missing. Take for example the following: DECLARE @CustomerID INT SET @CustomerID = 123152 SELECT […]
Read MoreUnmatched Indexes plan warnings
In SQL Server 2008 a new feature was introduced – Filtered Indexes. A filtered index is supposed to introduce performance gains by reducing the size of the index to discrete values. In order for a filtered index to be used, the query must not parameterize the value associated with the filtered index. If you use […]
Read MoreNo Join Predicate plan warning may be a red herring
Whenever I open a plan, I keep an eye out for plan warnings. These are sometimes really useful, but at times they may contain some inconsequential or incorrect information. One in particular is the “No Join Predicate”. Typically, this would be cause for alarm since this is an indicator of a cartesian join. This would […]
Read MoreParallel plans can be selected with scalar UDF’s
It’s a somewhat known thing that scalar user defined functions can prevent parallel plans from being selected. There is a catch. If the scalar function can be inlined, this rule does not apply. Inlining of scalar functions is available starting in SQL Server 2019 (compatibility level 150). Demo Query I will be using the following […]
Read MoreWhat’s my parallel query waiting on?
You might run into a query that is showing parallel waits (CXPACKET, CXCONSUMER, etc). Typically, the parallel tasks executing are doing something like consuming CPU, waiting on IO, etc. If your parallel tasks get hung up waiting on something it will hold up the query execution as a whole. Most monitoring methods will show the […]
Read MoreImproving performance of SUBSTRING queries
Sometimes I see queries that use SUBSTRING in the query predicate. This makes the query non-sargable (i.e. indexes aren’t usable). Example query: SELECT * FROM CustomerAccount WHERE SUBSTRING(AccountNbr, 0, CHARINDEX(‘-‘, AccountNbr)) = ‘999999’ This query is searching for an account number where everything up to the hyphen is stripped out. Applying the SUBSTRING function causes […]
Read MoreExecution plan shortcuts causing random long executions
I recently worked with a customer where they had a query that despite taking a consistent execution plan had very different runtimes (as identified by the plan hash). This was not a case of parameter sniffing – instead this is what I refer to as plan shortcuts. The query I’m using for this example is […]
Read MoreSQL Server compile locks
While they don’t occur very often, compile locks can become a problem with stored procedures. This post will outline some common things to look for that can cause compile locks and how to address them. What is a compile lock? SQL Server keeps one version of an execution plan in the plan cache at any […]
Read MoreAre you searching for a Precise I3 replacement?
I occasionally do consulting engagements for customers although our primary business is SQLGrease (database observability, performance monitoring). I had a customer that used Precise I3. Not a bad product, but it needed some updating as it had some quirks as they migrated from adobe flash to a web version. They were acquired by Idera and […]
Read More