queryinsights.long_running_queries(Transact-SQL)

适用于:Microsoft Fabric 中的 SQL 分析终结点和 Microsoft Fabric 中的仓库

queryinsights.long_running_queries Microsoft Fabric Data Warehouse视图提供了关于SQL查询执行时间的信息。

列名称 数据类型 描述
last_run_start_time datetime2 最新查询执行的时间。
last_run_command varchar(8000) 上次查询执行的文本。
median_total_elapsed_time_ms int 跨运行中的查询执行时间(ms)中值。
number_of_runs int 执行查询的总次数。
number_of_accelerated_runs int 查询被 加速的总次数。
last_run_total_elapsed_time_ms int 上次执行所花费的时间(ms)。
last_dist_statement_id uniqueidentifier 将查询 queryinsights.exec_requests_history链接到的 ID。
last_run_session_id smallint 上次执行的用户会话 ID。
query_hash varchar(200) 查询时计算的二叉哈希值,用于识别语义相似的查询。 例如,相同但参数化值不同的查询共享一个 query_hash。 利用查询哈希来关联查询洞察视图。 有关详细信息,请参阅 Query Insights - 聚合。

权限

你需要在 Microsoft Fabric 中访问 SQL 分析端点,或在 Premium 容量工作空间内访问 Microsoft Fabric 中的 Warehouse,且权限为贡献者或更高权限。

Example

你可以找到长期查询的性能,例如:

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

下一步