sp_BlitzCache not grouping by Query Hash
This repro is against the StackOverflow DB. Can be Repro'd against SQL14 in the lab.
use StackOverflow;
GO
DBCC FREEPROCCACHE;
GO
SELECT
Score,
Count(*) AS CommentCount
FROM dbo.Comments
WHERE UserId = 557499
GROUP BY Score
ORDER BY Score DESC;
GO
SELECT
Score,
Count(*) AS CommentCount
FROM dbo.Comments
WHERE UserId = 26837
GROUP BY Score
ORDER BY Score DESC;
GO
SELECT
Score,
Count(*) AS CommentCount
FROM dbo.Comments
WHERE UserId = 22656
GROUP BY Score
ORDER BY Score DESC;
GO
exec sp_BlitzCache @results='Expert';
expected result: one line showing 1 query with 3 executions Actual result: three lines with 1 execution each, all with Query Hash 0x4046BC7C48BEC501
Fixing this will be mildly complicated because there can be different plans-- so you'll have to just pick one and warn on that. In the example here one throws " Missing Indexes (1), Parallel" whereas the others don't.
They all warn "Multiple Plans" and they all have "# Plans" = 3 and "Distinct Plans"=1, with Executions=1.
The # of plans is right, but the Distinct Plans is not.
The refactoring for this will likely show the worst offending metrics from a query hash and then a user could use a hypothetical "more info" query to get all of the details for one query (see #5)
This issue was moved to BrentOzarULTD/sp_BlitzCache#6