Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/PlanViewer.Core/Services/QueryStoreService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ public static async Task<List<QueryStorePlan>> FetchTopPlansAsync(
// into #top_plans. Still no nvarchar(max) columns.
//
// Phase 4: Final SELECT — join only the TOP N winners to query_text, plan
// XML, and query metadata. Uses OUTER APPLY + TRY_CONVERT for
// safe plan XML retrieval.
// XML, and query metadata. query_plan is nvarchar(max) on the
// catalog view, so it's referenced directly without conversion.
//
// OPTION (RECOMPILE) on aggregation phases prevents parameter sniffing on
// date range parameters producing bad plans for different time windows.
Expand Down Expand Up @@ -299,7 +299,7 @@ FROM ranked AS r
tp.query_id,
tp.plan_id,
qt.query_sql_text,
TRY_CONVERT(nvarchar(max), p.query_plan) AS query_plan,
p.query_plan,
tp.avg_cpu_us,
tp.avg_duration_us,
tp.avg_reads,
Expand Down Expand Up @@ -980,7 +980,7 @@ FROM ranked
r.query_id,
r.plan_id,
qt.query_sql_text,
TRY_CONVERT(nvarchar(max), p.query_plan) AS plan_xml,
p.query_plan AS plan_xml,
r.module_name,
r.total_cpu_us,
r.total_duration_us,
Expand Down Expand Up @@ -1283,7 +1283,7 @@ FROM ranked
r.query_id,
r.plan_id,
qt.query_sql_text,
TRY_CONVERT(nvarchar(max), p.query_plan) AS plan_xml,
p.query_plan AS plan_xml,
r.total_cpu_us,
r.total_duration_us,
r.total_reads,
Expand Down