简体   繁体   English

找出在SQL Azure中增加DTU的查询

[英]Find out which query increasing DTU in SQL Azure

I am using SQL Azure SQL Server for my App. 我在我的应用程序中使用SQL Azure SQL Server。 The DB tier, which my app was in was working perfectly till recently and the avg DTU usage was under control. 我的应用程序所在的数据库层一直运行到最近,avg DTU的使用受到控制。 But off late, during peak hours, the DTU spikes to touch 100% consistently. 但是在高峰时段,DTU的峰值持续达到100%。 Upgrading to the Next tier is an option, but first i want to figure out which query is responsible for this. 升级到下一层是一个选项,但首先我想弄清楚哪个查询对此负责。 Is this possible to find in Azure, which query made the DTU jump to 100%? 这可以在Azure中找到,哪个查询使DTU跳转到100%?

Simply put DTU is a blend of CPU,IO,Memory you will get based on your service tier..It would be really great if there is column which shows how much DTU the query used compared to total DTU.. 简单地说DTU是CPU,IO,内存的混合物,你将根据你的服务等级得到它。如果有一个列显示查询使用的DTU与总DTU的比较,那将会非常棒。

I would deal this issue in two steps.. 我会分两步处理这个问题。

Step1: 步骤1:
Find out Which metric is consistently more than 90% 找出哪个指标始终超过90%

--This DMV stores DTU usage for every 15 seconds upto 14 days.. - 这个DMV每15秒存储一次DTU使用,最多14天。

SELECT  
    AVG(avg_cpu_percent) AS 'Average CPU Utilization In Percent', 
    MAX(avg_cpu_percent) AS 'Maximum CPU Utilization In Percent', 
    AVG(avg_data_io_percent) AS 'Average Data IO In Percent', 
    MAX(avg_data_io_percent) AS 'Maximum Data IO In Percent', 
    AVG(avg_log_write_percent) AS 'Average Log Write Utilization In Percent', 
    MAX(avg_log_write_percent) AS 'Maximum Log Write Utilization In Percent', 
    AVG(avg_memory_usage_percent) AS 'Average Memory Usage In Percent', 
    MAX(avg_memory_usage_percent) AS 'Maximum Memory Usage In Percent' 
FROM sys.dm_db_resource_stats; 

Step2: 第2步:
If you see any of the above metric consistently more than 90%,you can tune those queries.. 如果您看到上述任何指标始终超过90%,则可以调整这些查询。

For Example,if cpu is more than 90% ,you can start tracking the queries which are having high cpu usage and tune them.. 例如,如果cpu超过90%,您可以开始跟踪具有高CPU使用率的查询并调整它们。

Updated as of 20171701: 自20171701更新:
SQLAzure introduced Query Performance insight,which shows DTU used by a Query.You will have to enable Querystore for this to work.. SQLAzure引入了Query Performance insight,它显示了Query使用的DTU。您必须启用Querystore才能使其工作。

在此输入图像描述

As you can see from screenshot above,you can see exact DTU usage for each query 从上面的屏幕截图中可以看出,您可以看到每个查询的确切DTU用法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM