iT邦幫忙

0

請問SQL Server如何select出某個時段所有SQL的CPU耗用、執行時間、記憶體占用嗎?

請問SQL Server如何select出某個時段所有SQL的CPU耗用、執行時間、記憶體占用嗎?

想要 select * from 分析報表 where 時間>='2021-01-01' and 時間<='2021-03-01'
查詢出以下效果:

時間 SQL 執行時間(s) CPU% 記憶體(KB)
1/1/2021 15:15 update xxx where id = xxx set v = xxx 500 7% 50
1/2/2021 15:15 select * from xxx where xxx = xxx 30 2% 1222
2/2/2021 15:15 delete xxx where xxx = xxx and yyy = yyy 72000 50% 20
https://docs.microsoft.com/zh-tw/sql/relational-databases/performance-monitor/monitor-resource-usage-system-monitor?view=sql-server-ver15
官網有,自行操作捏
工程詩 iT邦新手 4 級 ‧ 2021-10-19 17:04:15 檢舉
感謝!
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

2 個回答

3
石頭
iT邦高手 1 級 ‧ 2021-10-19 11:19:52
最佳解答

你可以嘗試使用 whoisactive 裡面有很多欄位對於 prod support 很有幫助,他是 snapshot sqlserver dmv 所以 sanpshot 時間間隔可以依照你需求調整(網路上有許多文章可以參考)

https://www.youtube.com/watch?v=Hgi_glU1mko 教學使用 whoisactive troubleshooting 問題

如果你 sqlserver 版本支援 query store 也可以考慮使用 query store

工程詩 iT邦新手 4 級 ‧ 2021-10-19 17:04:28 檢舉

感謝! 太有幫助了!

我要發表回答

立即登入回答