@@ -1375,7 +1375,22 @@ BEGIN
13751375 EXEC sp_executesql @sql, N ' @Top INT, @min_duration INT' , @Top, @DurationFilter_i;
13761376END
13771377
1378+ /* Update ##bou_BlitzCacheProcs to get Stored Proc info
1379+ * This should get totals for all statements in a Stored Proc
1380+ */
13781381
1382+ UPDATE b
1383+ SET
1384+ b .QueryHash = b2 .QueryHash ,
1385+ b .MinReturnedRows = b2 .MinReturnedRows ,
1386+ b .MaxReturnedRows = b2 .MaxReturnedRows ,
1387+ b .AverageReturnedRows = b2 .AverageReturnedRows ,
1388+ b .TotalReturnedRows = b2 .TotalReturnedRows ,
1389+ b .LastReturnedRows = b2 .LastReturnedRows
1390+ FROM ##bou_BlitzCacheProcs b
1391+ JOIN ##bou_BlitzCacheProcs b2
1392+ ON b2 .SqlHandle = b .SqlHandle
1393+ WHERE b .QueryHash IS NULL
13791394
13801395/* Compute the total CPU, etc across our active set of the plan cache.
13811396 * Yes, there's a flaw - this doesn't include anything outside of our @Top
@@ -1562,7 +1577,7 @@ OPTION (RECOMPILE) ;
15621577;WITH XMLNAMESPACES(' http://schemas.microsoft.com/sqlserver/2004/07/showplan' AS p)
15631578, c1 AS (
15641579SELECT
1565- QueryPlanCost_check = CASE WHEN QueryType LIKE ' %Stored Procedure%' THEN
1580+ QueryPlanCost_check = CASE WHEN QueryType LIKE ' %Procedure%' THEN
15661581 statement .value (' sum(/p:StmtSimple/@StatementSubTreeCost)' , ' float' )
15671582 ELSE
15681583 statement .value (' sum(/p:StmtSimple[xs:hexBinary(substring(@QueryPlanHash, 3)) = xs:hexBinary(sql:column("QueryPlanHash"))]/@StatementSubTreeCost)' , ' float' )
@@ -1684,11 +1699,6 @@ WITH XMLNAMESPACES('http://schemas.microsoft.com/sqlserver/2004/07/showplan' AS
16841699UPDATE ##bou_BlitzCacheProcs
16851700SET NumberOfDistinctPlans = distinct_plan_count,
16861701 NumberOfPlans = number_of_plans,
1687- QueryPlanCost = CASE WHEN QueryType LIKE ' %Stored Procedure%' THEN
1688- QueryPlan .value (' sum(//p:StmtSimple/@StatementSubTreeCost)' , ' float' )
1689- ELSE
1690- QueryPlan .value (' sum(//p:StmtSimple[xs:hexBinary(substring(@QueryPlanHash, 3)) = xs:hexBinary(sql:column("QueryPlanHash"))]/@StatementSubTreeCost)' , ' float' )
1691- END ,
16921702 missing_index_count = QueryPlan .value (' count(//p:MissingIndexGroup)' , ' int' ) ,
16931703 unmatched_index_count = QueryPlan .value (' count(//p:UnmatchedIndexes/p:Parameterization/p:Object)' , ' int' ) ,
16941704 plan_multiple_plans = CASE WHEN distinct_plan_count < number_of_plans THEN 1 END ,
0 commit comments