Why do no nodes appear in summary

博雄 胡 585 Reputation points
2025-03-14T03:29:05.1+00:00

1

I thought it would have at least one node, but it didn't. Did I misunderstand its concept

SQL Server Database Engine
{count} votes

Accepted answer
  1. Erland Sommarskog 120.2K Reputation points MVP
    2025-03-14T16:49:16.7733333+00:00

    I used Profiler to find what queries SSMS are submitting. The first query below is for the graph to the left, while the second is for the currently selected bar and its result is depicted to the right. The third query seems to feed the panel on the far right.

    Why the result of the second query is not depicted I don't know. Maybe they get the scale wrong and the dot ends up outside the graph. It seems that the second query still returns something, since the third query is feed a plan id, and this plan id must come from the second query. (The first does not return any plan id.)

    exec sp_executesql N'SELECT TOP (@results_row_count)
        p.query_id query_id,
        q.object_id object_id,
        ISNULL(OBJECT_NAME(q.object_id),'''') object_name,
        qt.query_sql_text query_sql_text,
        ROUND(CONVERT(float, SUM(rs.avg_duration*rs.count_executions))*0.001,2) total_duration,
        SUM(rs.count_executions) count_executions,
        COUNT(distinct p.plan_id) num_plans
    FROM sys.query_store_runtime_stats rs
        JOIN sys.query_store_plan p ON p.plan_id = rs.plan_id
        JOIN sys.query_store_query q ON q.query_id = p.query_id
        JOIN sys.query_store_query_text qt ON q.query_text_id = qt.query_text_id
    WHERE NOT (rs.first_execution_time > @interval_end_time OR rs.last_execution_time < @interval_start_time)
    GROUP BY p.query_id, qt.query_sql_text, q.object_id
    HAVING COUNT(distinct p.plan_id) >= 1
    ORDER BY total_duration DESC',N'@results_row_count int,@interval_start_time datetimeoffset(7),@interval_end_time datetimeoffset(7)',@results_row_count=25,@interval_start_time='2025-03-14 16:34:57.4953000 +01:00',@interval_end_time='2025-03-14 17:34:57.4963064 +01:00'
    exec sp_executesql N'WITH 
        bucketizer as 
        (
            SELECT
                rs.plan_id as plan_id,
                rs.execution_type as execution_type,
                SUM(rs.count_executions) count_executions,
                DATEADD(mi, ((DATEDIFF(mi, 0, rs.last_execution_time))),0 ) as bucket_start,
                DATEADD(mi, (1 + (DATEDIFF(mi, 0, rs.last_execution_time))), 0) as bucket_end,
                ROUND(CONVERT(float, SUM(rs.avg_duration*rs.count_executions))/NULLIF(SUM(rs.count_executions), 0)*0.001,2) as avg_duration,
                ROUND(CONVERT(float, MAX(rs.max_duration))*0.001,2) as max_duration,
                ROUND(CONVERT(float, MIN(rs.min_duration))*0.001,2) as min_duration,
                ROUND(CONVERT(float, SQRT( SUM(rs.stdev_duration*rs.stdev_duration*rs.count_executions)/NULLIF(SUM(rs.count_executions), 0)))*0.001,2) as stdev_duration,
                ISNULL(ROUND(CONVERT(float, (SQRT( SUM(rs.stdev_duration*rs.stdev_duration*rs.count_executions)/NULLIF(SUM(rs.count_executions), 0))*SUM(rs.count_executions)) / NULLIF(SUM(rs.avg_duration*rs.count_executions), 0)),2), 0) as variation_duration,
                ROUND(CONVERT(float, SUM(rs.avg_duration*rs.count_executions))*0.001,2) as total_duration
            FROM
                sys.query_store_runtime_stats rs
                JOIN sys.query_store_plan p ON p.plan_id = rs.plan_id
            WHERE
                p.query_id = @query_id
            AND NOT (rs.first_execution_time > @interval_end_time OR rs.last_execution_time < @interval_start_time)
            GROUP BY
                rs.plan_id,
                rs.execution_type,
                DATEDIFF(mi, 0, rs.last_execution_time)
        ),
        is_forced as
        (
            SELECT is_forced_plan, plan_id
              FROM sys.query_store_plan
        )
    SELECT b.plan_id as plan_id,
        is_forced_plan,
        execution_type,
        count_executions,
        SWITCHOFFSET(bucket_start, DATEPART(tz, @interval_start_time)) AS bucket_start,
        SWITCHOFFSET(bucket_end, DATEPART(tz, @interval_start_time)) AS bucket_end,
        avg_duration,
        max_duration,
        min_duration,
        stdev_duration,
        variation_duration,
        total_duration
    FROM bucketizer b
    JOIN is_forced f ON f.plan_id = b.plan_id',N'@query_id bigint,@interval_start_time datetimeoffset(7),@interval_end_time datetimeoffset(7)',@query_id=59,@interval_start_time='2025-03-14 16:34:57.6714296 +01:00',@interval_end_time='2025-03-14 17:34:57.6714296 +01:00'
    
    exec sp_executesql N'SELECT
        p.is_forced_plan,
        p.query_plan
    FROM
        sys.query_store_plan p
    WHERE
        p.query_id = @query_id
        AND p.plan_id = @plan_id',N'@query_id bigint,@plan_id bigint',@query_id=59,@plan_id=28
    
    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.