@@ -786,6 +786,8 @@ ELSE QUOTENAME(MAX(pl.schema_name)) + N'.' + QUOTENAME(MAX(pl.object_name))
786786 avg_logical_writes = SUM(pl.total_logical_writes) / NULLIF(SUM(pl.execution_count), 0),
787787 total_physical_reads = SUM(pl.total_physical_reads),
788788 avg_physical_reads = SUM(pl.total_physical_reads) / NULLIF(SUM(pl.execution_count), 0),
789+ min_physical_reads = MIN(pl.min_physical_reads),
790+ max_physical_reads = MAX(pl.max_physical_reads),
789791 total_rows = SUM(pl.total_rows),
790792 avg_rows = SUM(pl.total_rows) / NULLIF(SUM(pl.execution_count), 0),
791793 min_rows = MIN(pl.min_rows),
@@ -849,22 +851,24 @@ USE HINT('ENABLE_PARALLEL_PLAN_PREFERENCE')
849851 AvgLogicalWrites = reader . IsDBNull ( 18 ) ? null : reader . GetInt64 ( 18 ) ,
850852 TotalPhysicalReads = reader . IsDBNull ( 19 ) ? 0 : reader . GetInt64 ( 19 ) ,
851853 AvgPhysicalReads = reader . IsDBNull ( 20 ) ? null : reader . GetInt64 ( 20 ) ,
852- TotalRows = reader . IsDBNull ( 21 ) ? 0 : reader . GetInt64 ( 21 ) ,
853- AvgRows = reader . IsDBNull ( 22 ) ? null : reader . GetInt64 ( 22 ) ,
854- MinRows = reader . IsDBNull ( 23 ) ? null : reader . GetInt64 ( 23 ) ,
855- MaxRows = reader . IsDBNull ( 24 ) ? null : reader . GetInt64 ( 24 ) ,
856- MinDop = reader . IsDBNull ( 25 ) ? null : reader . GetInt16 ( 25 ) ,
857- MaxDop = reader . IsDBNull ( 26 ) ? null : reader . GetInt16 ( 26 ) ,
858- MinGrantKb = reader . IsDBNull ( 27 ) ? null : reader . GetInt64 ( 27 ) ,
859- MaxGrantKb = reader . IsDBNull ( 28 ) ? null : reader . GetInt64 ( 28 ) ,
860- TotalSpills = reader . IsDBNull ( 29 ) ? 0 : reader . GetInt64 ( 29 ) ,
861- MinSpills = reader . IsDBNull ( 30 ) ? null : reader . GetInt64 ( 30 ) ,
862- MaxSpills = reader . IsDBNull ( 31 ) ? null : reader . GetInt64 ( 31 ) ,
863- QueryText = reader . IsDBNull ( 32 ) ? null : reader . GetString ( 32 ) ,
864- QueryPlanXml = reader . IsDBNull ( 33 ) ? null : reader . GetString ( 33 ) ,
865- QueryPlanHash = reader . IsDBNull ( 34 ) ? null : reader . GetString ( 34 ) ,
866- SqlHandle = reader . IsDBNull ( 35 ) ? null : reader . GetString ( 35 ) ,
867- PlanHandle = reader . IsDBNull ( 36 ) ? null : reader . GetString ( 36 )
854+ MinPhysicalReads = reader . IsDBNull ( 21 ) ? null : reader . GetInt64 ( 21 ) ,
855+ MaxPhysicalReads = reader . IsDBNull ( 22 ) ? null : reader . GetInt64 ( 22 ) ,
856+ TotalRows = reader . IsDBNull ( 23 ) ? 0 : reader . GetInt64 ( 23 ) ,
857+ AvgRows = reader . IsDBNull ( 24 ) ? null : reader . GetInt64 ( 24 ) ,
858+ MinRows = reader . IsDBNull ( 25 ) ? null : reader . GetInt64 ( 25 ) ,
859+ MaxRows = reader . IsDBNull ( 26 ) ? null : reader . GetInt64 ( 26 ) ,
860+ MinDop = reader . IsDBNull ( 27 ) ? null : reader . GetInt16 ( 27 ) ,
861+ MaxDop = reader . IsDBNull ( 28 ) ? null : reader . GetInt16 ( 28 ) ,
862+ MinGrantKb = reader . IsDBNull ( 29 ) ? null : reader . GetInt64 ( 29 ) ,
863+ MaxGrantKb = reader . IsDBNull ( 30 ) ? null : reader . GetInt64 ( 30 ) ,
864+ TotalSpills = reader . IsDBNull ( 31 ) ? 0 : reader . GetInt64 ( 31 ) ,
865+ MinSpills = reader . IsDBNull ( 32 ) ? null : reader . GetInt64 ( 32 ) ,
866+ MaxSpills = reader . IsDBNull ( 33 ) ? null : reader . GetInt64 ( 33 ) ,
867+ QueryText = reader . IsDBNull ( 34 ) ? null : reader . GetString ( 34 ) ,
868+ QueryPlanXml = reader . IsDBNull ( 35 ) ? null : reader . GetString ( 35 ) ,
869+ QueryPlanHash = reader . IsDBNull ( 36 ) ? null : reader . GetString ( 36 ) ,
870+ SqlHandle = reader . IsDBNull ( 37 ) ? null : reader . GetString ( 37 ) ,
871+ PlanHandle = reader . IsDBNull ( 38 ) ? null : reader . GetString ( 38 )
868872 } ) ;
869873 }
870874
@@ -1098,7 +1102,16 @@ public async Task<List<QueryStoreItem>> GetQueryStoreDataAsync(int hoursBack = 2
10981102 is_forced_plan = MAX(CONVERT(tinyint, qsd.is_forced_plan)),
10991103 compatibility_level = MAX(qsd.compatibility_level),
11001104 query_sql_text = CONVERT(nvarchar(max), MAX(qsd.query_sql_text)),
1101- query_plan_hash = CONVERT(nvarchar(20), MAX(qsd.query_plan_hash), 1)
1105+ query_plan_hash = CONVERT(nvarchar(20), MAX(qsd.query_plan_hash), 1),
1106+ force_failure_count = SUM(qsd.force_failure_count),
1107+ last_force_failure_reason_desc = MAX(qsd.last_force_failure_reason_desc),
1108+ plan_forcing_type = MAX(qsd.plan_forcing_type),
1109+ min_clr_time_ms = MIN(qsd.min_clr_time) / 1000.0,
1110+ max_clr_time_ms = MAX(qsd.max_clr_time) / 1000.0,
1111+ min_num_physical_io_reads = MIN(qsd.min_num_physical_io_reads),
1112+ max_num_physical_io_reads = MAX(qsd.max_num_physical_io_reads),
1113+ min_log_bytes_used = MIN(qsd.min_log_bytes_used),
1114+ max_log_bytes_used = MAX(qsd.max_log_bytes_used)
11021115 FROM collect.query_store_data AS qsd
11031116 WHERE (
11041117 (@useCustomDates = 0 AND qsd.server_last_execution_time >= DATEADD(HOUR, -@hoursBack, SYSDATETIME()))
@@ -1172,7 +1185,16 @@ USE HINT('ENABLE_PARALLEL_PLAN_PREFERENCE')
11721185 IsForcedPlan = ! reader . IsDBNull ( 35 ) && reader . GetByte ( 35 ) == 1 ,
11731186 CompatibilityLevel = reader . IsDBNull ( 36 ) ? null : reader . GetInt16 ( 36 ) ,
11741187 QuerySqlText = reader . IsDBNull ( 37 ) ? null : reader . GetString ( 37 ) ,
1175- QueryPlanHash = reader . IsDBNull ( 38 ) ? null : reader . GetString ( 38 )
1188+ QueryPlanHash = reader . IsDBNull ( 38 ) ? null : reader . GetString ( 38 ) ,
1189+ ForceFailureCount = reader . IsDBNull ( 39 ) ? null : reader . GetInt64 ( 39 ) ,
1190+ LastForceFailureReasonDesc = reader . IsDBNull ( 40 ) ? null : reader . GetString ( 40 ) ,
1191+ PlanForcingType = reader . IsDBNull ( 41 ) ? null : reader . GetString ( 41 ) ,
1192+ MinClrTimeMs = reader . IsDBNull ( 42 ) ? null : Convert . ToDouble ( reader . GetValue ( 42 ) , CultureInfo . InvariantCulture ) ,
1193+ MaxClrTimeMs = reader . IsDBNull ( 43 ) ? null : Convert . ToDouble ( reader . GetValue ( 43 ) , CultureInfo . InvariantCulture ) ,
1194+ MinNumPhysicalIoReads = reader . IsDBNull ( 44 ) ? null : reader . GetInt64 ( 44 ) ,
1195+ MaxNumPhysicalIoReads = reader . IsDBNull ( 45 ) ? null : reader . GetInt64 ( 45 ) ,
1196+ MinLogBytesUsed = reader . IsDBNull ( 46 ) ? null : reader . GetInt64 ( 46 ) ,
1197+ MaxLogBytesUsed = reader . IsDBNull ( 47 ) ? null : reader . GetInt64 ( 47 )
11761198 // QueryPlanXml is fetched on-demand via GetQueryStorePlanXmlAsync
11771199 } ) ;
11781200 }
0 commit comments