在阅读了有关如何检查DTU之后,我现在有以下查询(基于以下MSDN文章中的一个:https://azure.microsoft.com/en-us/documentation/articles/sql-database-upgrade-new-service-tiers/)
Select avg(unsum) as avg_DTU_percent,database_name from (
SELECT start_time,(SELECT Max(v)
FROM (VALUES (avg_cpu_percent)
, (avg_physical_data_read_percent)
, (avg_log_write_percent)
) AS value(v)) AS [unsum],database_name
FROM sys.resource_stats
WHERE database_name = '<DBNAME>')as rc GROUP BY database_name;
我想修改它以在服务器中的所有数据库上运行,这意味着我要删除where database_name并使用group by 但我似乎没有使用真正的sql太长时间而且缺少一些东西
有没有办法在内部查询之前对数据进行分区,以便我可以轻松获取数据?
答案 0 :(得分:4)
SELECT database_name
,(SELECT Max(v)
FROM (VALUES (max(avg_cpu_percent))
, (max(avg_data_io_percent))
, (max(avg_log_write_percent))
) AS value(v)) AS [max_DTU_percent]
FROM sys.resource_stats group by database_name
会记录最高的DTU百分比。
SELECT start_time, end_time, database_name
,(SELECT Max(v)
FROM (VALUES (avg_cpu_percent)
, (avg_data_io_percent)
, (avg_log_write_percent)
) AS value(v)) AS [max_DTU_percent]
FROM sys.resource_stats
ORDER BY end_time
每五分钟会给你一个清单,以便你可以看到数据范围。