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 MoreHow to measure query runtime when developing/testing – part 3
This is the third in a 3 part post on measuring query runtimes (previous posts Part 1 Part 2) This post covers using live query plans. This feature is available on SQL Server 2016 or later. Live query statistics allow you to see where time is being spent as a query executes. It’s similar to […]
Read MoreDeadlock graphs now contain query hashes
In the past a problem we had when building SQLGrease was deadlock graphs only containing sql handles and statement start offsets. While this might give you the statement for parameterized adhoc sql or a stored procedure, it does not account for a cluttered plan cache due to non parameterized sql. This previous post explains the […]
Read More