Skip to content

Latest commit

 

History

History
79 lines (73 loc) · 7.39 KB

File metadata and controls

79 lines (73 loc) · 7.39 KB
title sys.query_store_query (Transact-SQL) | Microsoft Docs
ms.custom
ms.date 01/23/2019
ms.prod sql
ms.prod_service database-engine, sql-database
ms.reviewer
ms.technology system-objects
ms.topic language-reference
f1_keywords
QUERY_STORE_QUERY
SYS.QUERY_STORE_QUERY_TSQL
SYS.QUERY_STORE_QUERY
QUERY_STORE_QUERY_TSQL
dev_langs
TSQL
helpviewer_keywords
query_store_query catalog view
sys.query_store_query catalog view
ms.assetid bdee149e-7556-4fc3-8242-925dd4b7b6ac
author stevestein
ms.author sstein
monikerRange =azuresqldb-current||>=sql-server-2016||= azure-sqldw-latest||=sqlallproducts-allversions||>=sql-server-linux-2017||=azuresqldb-mi-current

sys.query_store_query (Transact-SQL)

[!INCLUDEtsql-appliesto-ss2016-asdb-asdw-xxx-md]

Contains information about the query and its associated overall aggregated runtime execution statistics.

Column name Data type Description
query_id bigint Primary key.
query_text_id bigint Foreign key. Joins to sys.query_store_query_text (Transact-SQL)
context_settings_id bigint Foreign key. Joins to sys.query_context_settings (Transact-SQL).
Note: Azure SQL Data Warehouse will always return zero (0).
object_id bigint ID of the database object that the query is part of (stored procedure, trigger, CLR UDF/UDAgg, etc.). 0 if the query is not executed as part of a database object (ad-hoc query).
Note: Azure SQL Data Warehouse will always return zero (0).
batch_sql_handle varbinary(64) ID of the statement batch the query is part of. Populated only if query references temporary tables or table variables.
Note: Azure SQL Data Warehouse will always return NULL.
query_hash binary(8) MD5 hash of the individual query, based on the logical query tree. Includes optimizer hints.
is_internal_query bit The query was generated internally.
Note: Azure SQL Data Warehouse will always return zero (0).
query_parameterization_type tinyint Kind of parameterization:

0 - None

1 - User

2 - Simple

3 - Forced
Note: Azure SQL Data Warehouse will always return zero (0).
query_parameterization_type_desc nvarchar(60) Textual description for the parameterization type.
Note: Azure SQL Data Warehouse will always return None.
initial_compile_start_time datetimeoffset Compile start time.
last_compile_start_time datetimeoffset Compile start time.
last_execution_time datetimeoffset Last execution time refers to the last end time of the query/plan.
last_compile_batch_sql_handle varbinary(64) Handle of the last SQL batch in which query was used last time. It can be provided as input to sys.dm_exec_sql_text (Transact-SQL) to get the full text of the batch.
Note: Azure SQL Data Warehouse will always return NULL.
last_compile_batch_offset_start bigint Information that can be provided to sys.dm_exec_sql_text along with last_compile_batch_sql_handle.
Note: Azure SQL Data Warehouse will always return zero (0).
last_compile_batch_offset_end bigint Information that can be provided to sys.dm_exec_sql_text along with last_compile_batch_sql_handle.
Note: Azure SQL Data Warehouse will always return zero (0).
count_compiles bigint Compilation statistics.
Note: Azure SQL Data Warehouse will always return one (1).
avg_compile_duration float Compilation statistics in microseconds.
last_compile_duration bigint Compilation statistics in microseconds.
avg_bind_duration float Binding statistics in microseconds.
Note: Azure SQL Data Warehouse will always return zero (0).
last_bind_duration bigint Binding statistics.
Note: Azure SQL Data Warehouse will always return zero (0).
avg_bind_cpu_time float Binding statistics.
Note: Azure SQL Data Warehouse will always return zero (0).
last_bind_cpu_time bigint Binding statistics.
Note: Azure SQL Data Warehouse will always return zero (0).
avg_optimize_duration float Optimization statistics in microseconds.
Note: Azure SQL Data Warehouse will always return zero (0).
last_optimize_duration bigint Optimization statistics.
Note: Azure SQL Data Warehouse will always return zero (0).
avg_optimize_cpu_time float Optimization statistics in microseconds.
Note: Azure SQL Data Warehouse will always return zero (0).
last_optimize_cpu_time bigint Optimization statistics.
Note: Azure SQL Data Warehouse will always return zero (0).
avg_compile_memory_kb float Compile memory statistics.
Note: Azure SQL Data Warehouse will always return zero (0).
last_compile_memory_kb bigint Compile memory statistics.
Note: Azure SQL Data Warehouse will always return zero (0).
max_compile_memory_kb bigint Compile memory statistics.
Note: Azure SQL Data Warehouse will always return zero (0).
is_clouddb_internal_query bit Always 0 in [!INCLUDEssNoVersion] on-premises.
Note: Azure SQL Data Warehouse will always return zero (0).

Permissions

Requires the VIEW DATABASE STATE permission.

See Also

sys.database_query_store_options (Transact-SQL)
sys.query_context_settings (Transact-SQL)
sys.query_store_plan (Transact-SQL)
sys.query_store_query_text (Transact-SQL)
sys.query_store_wait_stats (Transact-SQL)
sys.query_store_runtime_stats (Transact-SQL)
sys.query_store_runtime_stats_interval (Transact-SQL)
Monitoring Performance By Using the Query Store
Catalog Views (Transact-SQL)
Query Store Stored Procedures (Transact-SQL)
sys.fn_stmt_sql_handle_from_sql_stmt (Transact-SQL)