SQL:如何获得每个数据库或小时或......的执行查询数?

Eri*_*ker 8 sql statistics performancecounter sql-server-profiler sql-server-2008

是否有任何方法可以查看每小时,每个数据库/小时执行的查询数量,或一天中的平均查询数,或者......有趣的是什么?

仅供统计......我喜欢数字.我不能只使用Sql Server Profiler启动跟踪,因为当查询过多时,UI将崩溃.

SQL是否在某处跟踪某些基本的"已执行查询统计信息",或者我是否可以使用任何工具来获取此信息?

(我使用的是SQL Server 2008 R2)

RBa*_*ung 5

这应该工作:

select * 
from sys.dm_os_performance_counters
where counter_name = 'Batch Requests/sec'
Run Code Online (Sandbox Code Playgroud)

它实际上返回批量请求.您定期轮询此数字,然后使用此计算:

ReqsPerSec = (curr.Value - prev.Value) / (curr.time - prev.time)
Run Code Online (Sandbox Code Playgroud)