SQL-Server-First-Responder-Kit icon indicating copy to clipboard operation
SQL-Server-First-Responder-Kit copied to clipboard

sp_BlitzCache: SQL Server 2022 compat level breaks statement tracking

Open BrentOzar opened this issue 2 years ago • 0 comments

Version of the script SELECT @Version = '8.09', @VersionDate = '20220408';

What is the current behavior? In database compat levels 150 (2019) and prior, if you run sp_BlitzCache, you can see where a statement comes from: Screen Shot 2022-05-25 at 11 29 04 AM

In compat level 160 (2022), you cannot: Screen Shot 2022-05-25 at 11 29 48 AM

In addition, if you click on the plan for the stored procedure, you just see a "multiple plan" operator, which isn't useful: Screen Shot 2022-05-25 at 11 32 03 AM

If the current behavior is a bug, please provide the steps to reproduce. It's not really a bug in sp_BlitzCache, but just something we're going to have to think about if they actually try to ship SQL Server 2022 in this sad state, so here goes:

USE StackOverflow2013;
GO
CREATE INDEX Reputation ON dbo.Users(Reputation);
GO
CREATE OR ALTER PROCEDURE dbo.usp_UsersByReputation
  @Reputation int
AS
SELECT TOP 10000 *
FROM dbo.Users
WHERE Reputation=@Reputation
ORDER BY DisplayName;
GO

ALTER DATABASE CURRENT SET COMPATIBILITY_LEVEL = 150;
GO
EXEC dbo.usp_UsersByReputation @Reputation =1;
GO
sp_BlitzCache;
GO


ALTER DATABASE CURRENT SET COMPATIBILITY_LEVEL = 160;
GO
EXEC dbo.usp_UsersByReputation @Reputation =1;
GO
sp_BlitzCache;

What is the expected behavior? It's early in the design process, but depending on how Microsoft decides to ship the final product, we might have to:

  • Build in warnings about why we can't tell which statements are from which procs
  • Build a different way of doing this altogether

BrentOzar avatar May 25 '22 17:05 BrentOzar