sys.query_store_query (Transact-sql) sys.query_store_query (Transact-SQL)

适用于:Applies to: 是SQL Server 2016 (13.x)SQL Server 2016 (13.x)yesSQL Server 2016 (13.x)SQL Server 2016 (13.x) 及更高版本 是Azure SQL 数据库Azure SQL DatabaseYesAzure SQL 数据库Azure SQL Database 是Azure SQL 托管实例Azure SQL Managed InstanceYesAzure SQL 托管实例Azure SQL Managed Instance 是Azure Synapse AnalyticsAzure Synapse AnalyticsyesAzure Synapse AnalyticsAzure Synapse Analytics适用于:Applies to: 是SQL Server 2016 (13.x)SQL Server 2016 (13.x)yesSQL Server 2016 (13.x)SQL Server 2016 (13.x) and later 是Azure SQL 数据库Azure SQL DatabaseYesAzure SQL 数据库Azure SQL Database 是Azure SQL 托管实例Azure SQL Managed InstanceYesAzure SQL 托管实例Azure SQL Managed Instance 是Azure Synapse AnalyticsAzure Synapse AnalyticsyesAzure Synapse AnalyticsAzure Synapse Analytics

包含有关查询及其关联的总体运行时执行统计信息的信息。Contains information about the query and its associated overall aggregated runtime execution statistics.

列名称Column name 数据类型Data type 说明Description
query_idquery_id bigintbigint 主密钥。Primary key.
query_text_idquery_text_id bigintbigint 外键。Foreign key. 联接到 sys.query_store_query_text (transact-sql)Joins to sys.query_store_query_text (Transact-SQL)
context_settings_idcontext_settings_id bigintbigint 外键。Foreign key. 联接到 (transact-sql)sys.query_context_settings Joins to sys.query_context_settings (Transact-SQL).
注意: Azure Synapse Analytics 将始终返回零 (0) 。Note: Azure Synapse Analytics will always return zero (0).
object_idobject_id bigintbigint 查询所属的数据库对象的 ID (存储过程、触发器、CLR UDF/UDAgg 等 ) 。ID of the database object that the query is part of (stored procedure, trigger, CLR UDF/UDAgg, etc.). 如果查询未作为数据库对象的一部分执行,则为 0 (即席查询) 。0 if the query is not executed as part of a database object (ad-hoc query).
注意: Azure Synapse Analytics 将始终返回零 (0) 。Note: Azure Synapse Analytics will always return zero (0).
batch_sql_handlebatch_sql_handle varbinary(64)varbinary(64) 查询所属的语句批处理的 ID。ID of the statement batch the query is part of. 仅当查询引用临时表或表变量时才填充。Populated only if query references temporary tables or table variables.
注意: Azure Synapse Analytics 将始终返回 NULLNote: Azure Synapse Analytics will always return NULL.
query_hashquery_hash **二进制 (8) **binary(8) 基于逻辑查询树的单个查询的 MD5 哈希。MD5 hash of the individual query, based on the logical query tree. 包含优化器提示。Includes optimizer hints.
is_internal_queryis_internal_query bitbit 查询是在内部生成的。The query was generated internally.
注意: Azure Synapse Analytics 将始终返回零 (0) 。Note: Azure Synapse Analytics will always return zero (0).
query_parameterization_typequery_parameterization_type tinyinttinyint 参数化类型:Kind of parameterization:

0 - 无0 - None

1-用户1 - User

2-简单2 - Simple

3-强制3 - Forced
注意: Azure Synapse Analytics 将始终返回零 (0) 。Note: Azure Synapse Analytics will always return zero (0).
query_parameterization_type_descquery_parameterization_type_desc nvarchar(60)nvarchar(60) 参数化类型的文本说明。Textual description for the parameterization type.
注意: Azure Synapse Analytics 将始终返回 NoneNote: Azure Synapse Analytics will always return None.
initial_compile_start_timeinitial_compile_start_time datetimeoffsetdatetimeoffset 编译开始时间。Compile start time.
last_compile_start_timelast_compile_start_time datetimeoffsetdatetimeoffset 编译开始时间。Compile start time.
last_execution_timelast_execution_time datetimeoffsetdatetimeoffset 上次执行时间是指查询/计划的最后结束时间。Last execution time refers to the last end time of the query/plan.
last_compile_batch_sql_handlelast_compile_batch_sql_handle varbinary(64)varbinary(64) 上次使用查询的 SQL 批处理的句柄。Handle of the last SQL batch in which query was used last time. 它可作为输入提供给 sys.dm_exec_sql_text (transact-sql) ,以获取批处理的完整文本。It can be provided as input to sys.dm_exec_sql_text (Transact-SQL) to get the full text of the batch.
注意: Azure Synapse Analytics 将始终返回 NULLNote: Azure Synapse Analytics will always return NULL.
last_compile_batch_offset_startlast_compile_batch_offset_start bigintbigint 可提供给 sys.dm_exec_sql_text 的信息以及 last_compile_batch_sql_handle。Information that can be provided to sys.dm_exec_sql_text along with last_compile_batch_sql_handle.
注意: Azure Synapse Analytics 将始终返回零 (0) 。Note: Azure Synapse Analytics will always return zero (0).
last_compile_batch_offset_endlast_compile_batch_offset_end bigintbigint 可提供给 sys.dm_exec_sql_text 的信息以及 last_compile_batch_sql_handle。Information that can be provided to sys.dm_exec_sql_text along with last_compile_batch_sql_handle.
注意: Azure Synapse Analytics 将始终返回零 (0) 。Note: Azure Synapse Analytics will always return zero (0).
count_compilescount_compiles bigintbigint 编译统计信息。Compilation statistics.
注意: Azure Synapse Analytics 将始终返回一个 (1) 。Note: Azure Synapse Analytics will always return one (1).
avg_compile_durationavg_compile_duration floatfloat 编译统计信息(微秒)。Compilation statistics in microseconds.
last_compile_durationlast_compile_duration bigintbigint 编译统计信息(微秒)。Compilation statistics in microseconds.
avg_bind_durationavg_bind_duration floatfloat 绑定统计信息(微秒)。Binding statistics in microseconds.
注意: Azure Synapse Analytics 将始终返回零 (0) 。Note: Azure Synapse Analytics will always return zero (0).
last_bind_durationlast_bind_duration bigintbigint 绑定统计信息。Binding statistics.
注意: Azure Synapse Analytics 将始终返回零 (0) 。Note: Azure Synapse Analytics will always return zero (0).
avg_bind_cpu_timeavg_bind_cpu_time floatfloat 绑定统计信息。Binding statistics.
注意: Azure Synapse Analytics 将始终返回零 (0) 。Note: Azure Synapse Analytics will always return zero (0).
last_bind_cpu_timelast_bind_cpu_time bigintbigint 绑定统计信息。Binding statistics.
注意: Azure Synapse Analytics 将始终返回零 (0) 。Note: Azure Synapse Analytics will always return zero (0).
avg_optimize_durationavg_optimize_duration floatfloat 优化统计信息(微秒)。Optimization statistics in microseconds.
注意: Azure Synapse Analytics 将始终返回零 (0) 。Note: Azure Synapse Analytics will always return zero (0).
last_optimize_durationlast_optimize_duration bigintbigint 优化统计信息。Optimization statistics.
注意: Azure Synapse Analytics 将始终返回零 (0) 。Note: Azure Synapse Analytics will always return zero (0).
avg_optimize_cpu_timeavg_optimize_cpu_time floatfloat 优化统计信息(微秒)。Optimization statistics in microseconds.
注意: Azure Synapse Analytics 将始终返回零 (0) 。Note: Azure Synapse Analytics will always return zero (0).
last_optimize_cpu_timelast_optimize_cpu_time bigintbigint 优化统计信息。Optimization statistics.
注意: Azure Synapse Analytics 将始终返回零 (0) 。Note: Azure Synapse Analytics will always return zero (0).
avg_compile_memory_kbavg_compile_memory_kb floatfloat 编译内存统计信息。Compile memory statistics.
注意: Azure Synapse Analytics 将始终返回零 (0) 。Note: Azure Synapse Analytics will always return zero (0).
last_compile_memory_kblast_compile_memory_kb bigintbigint 编译内存统计信息。Compile memory statistics.
注意: Azure Synapse Analytics 将始终返回零 (0) 。Note: Azure Synapse Analytics will always return zero (0).
max_compile_memory_kbmax_compile_memory_kb bigintbigint 编译内存统计信息。Compile memory statistics.
注意: Azure Synapse Analytics 将始终返回零 (0) 。Note: Azure Synapse Analytics will always return zero (0).
is_clouddb_internal_queryis_clouddb_internal_query bitbit 在本地始终为 0 SQL ServerSQL ServerAlways 0 in SQL ServerSQL Server on-premises.
注意: Azure Synapse Analytics 将始终返回零 (0) 。Note: Azure Synapse Analytics will always return zero (0).

权限Permissions

需要 VIEW DATABASE STATE 权限。Requires the VIEW DATABASE STATE permission.

另请参阅See Also

sys.database_query_store_options (Transact-sql) sys.database_query_store_options (Transact-SQL)
sys.query_context_settings (Transact-sql) sys.query_context_settings (Transact-SQL)
sys.query_store_plan (Transact-sql) sys.query_store_plan (Transact-SQL)
sys.query_store_query_text (Transact-sql) sys.query_store_query_text (Transact-SQL)
sys.query_store_wait_stats (Transact-SQL)sys.query_store_wait_stats (Transact-SQL)
sys.query_store_runtime_stats (Transact-sql) sys.query_store_runtime_stats (Transact-SQL)
sys.query_store_runtime_stats_interval (Transact-sql) sys.query_store_runtime_stats_interval (Transact-SQL)
相关视图、函数和过程 Monitoring Performance By Using the Query Store
目录视图 (Transact-SQL) Catalog Views (Transact-SQL)
查询存储存储过程 (Transact-SQL) Query Store Stored Procedures (Transact-SQL)
sys.fn_stmt_sql_handle_from_sql_stmt (Transact-SQL)sys.fn_stmt_sql_handle_from_sql_stmt (Transact-SQL)