Edit

queryinsights.long_running_queries (Transact-SQL)

Applies to: SQL analytics endpoint in Microsoft Fabric and Warehouse in Microsoft Fabric

The queryinsights.long_running_queries view in Microsoft Fabric Data Warehouse provides information about SQL query execution times.

Column name Data type Description
last_run_start_time datetime2 Time of the most recent query execution.
last_run_command varchar(8000) Text of the last query execution.
median_total_elapsed_time_ms int Median query execution time (ms) across runs.
number_of_runs int Total number of times the query was executed.
number_of_accelerated_runs int Total number of times the query was accelerated.
last_run_total_elapsed_time_ms int Time taken by the last execution (ms).
last_dist_statement_id uniqueidentifier ID linking the query to queryinsights.exec_requests_history.
last_run_session_id smallint User session ID for the last execution.
query_hash varchar(200) Binary hash value calculated on the query and used to identify semantically similar queries. For example, queries that are identical but have different parameterized values share a query_hash. Use the query hash to correlate between Query Insight views. For more information, see Query Insights - Aggregation.

Permissions

You need access to a SQL analytics endpoint in Microsoft Fabric or Warehouse in Microsoft Fabric within a Premium capacity workspace with Contributor or higher permissions.

Example

You can find the performance of long-running queries, for example:

SELECT * 
FROM queryinsights.long_running_queries
WHERE last_run_command LIKE '%SALES DASHBOARD%'
ORDER BY median_total_elapsed_time_ms DESC;

Next step