[英]Queries executed in Azure Synapse dedicated SQL Pool by User?
How to get the list of queries executed in Azure Synapse Dedicated SQL Pool by user?如何获取用户在 Azure Synapse Dedicated SQL 池中执行的查询列表?
You can get the query details by either using Azure Query Store service which automatically captures a history of queries, plans, and runtime statistics, and retains these for your review or you can create your custom table in your database to capture all the required details.您可以使用 Azure查询存储服务来获取查询详细信息,该服务会自动捕获查询、计划和运行时统计信息的历史记录,并保留这些以供您查看,或者您可以在数据库中创建自定义表以捕获所有必需的详细信息。
Only Synapse Dedicated pool supports Query Store but it isn't enabled by default for new Azure Synapse Analytics databases.只有 Synapse 专用池支持查询存储,但默认情况下未为新的 Azure Synapse Analytics 数据库启用它。
Use the ALTER DATABASE
statement to enable the query store for a given database.使用ALTER DATABASE
语句为给定数据库启用查询存储。 For example:例如:
ALTER DATABASE <database_name>
SET QUERY_STORE = ON (OPERATION_MODE = READ_WRITE);
The following query returns information about queries and plans in the Query Store.以下查询返回有关查询存储中的查询和计划的信息。
SELECT Txt.query_text_id, Txt.query_sql_text, Pl.plan_id, Qry.*
FROM sys.query_store_plan AS Pl
INNER JOIN sys.query_store_query AS Qry
ON Pl.query_id = Qry.query_id
INNER JOIN sys.query_store_query_text AS Txt
ON Qry.query_text_id = Txt.query_text_id;
On the other side, if you want to create a table to track the history of all the queries, you can refer the answer given by SqlWorldWide on this similar thread .另一方面,如果您想创建一个表来跟踪所有查询的历史记录,您可以参考SqlWorldWide在这个类似线程上给出的答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.