How to view history of queries (all OR over a long period) performed on database which is hosted on Azure?

前端 未结 2 1911
有刺的猬
有刺的猬 2021-02-06 14:34

For a database hosted on Azure, i can view the recent history of the queries performed on it. This is through the Azure portal > Database > Manage > Administration > Que

2条回答
  •  悲哀的现实
    2021-02-06 15:29

    Here is a query I found useful to see the most executed queries on my Azure SQL Server database:

    SELECT TOP 10 execution_count, statement_text
    FROM (
        SELECT QS.*,
        SUBSTRING(
            ST.text,
            (QS.statement_start_offset/2) + 1,
            ((
                CASE statement_end_offset
                WHEN -1 THEN DATALENGTH(st.text)
                ELSE QS.statement_end_offset END
                - QS.statement_start_offset
            ) /2) 
            + 1
        ) AS statement_text
        FROM sys.dm_exec_query_stats AS QS
        CROSS APPLY sys.dm_exec_sql_text(QS.sql_handle) as ST
    ) AS query_stats
    WHERE statement_text LIKE 'UPDATE%'
    ORDER BY execution_count DESC
    

    Source: March Madness - SQL Azure - sys.dm_exec_query_plan | SQLRockstar | Thomas LaRock

提交回复
热议问题