SQL壓力測試用的語句和相關計數器


將數據庫中所有表的所有的內容選一遍:

 

IF object_id('tempdb..#temp')   is   not   null     
BEGIN
DROP TABLE #temp
END

DECLARE @index int
DECLARE @count int
  DECLARE @schemaname varchar(50)
DECLARE @tablename varchar(50)
set @index=1
set @count=(select count(*) from sysobjects where xtype='U')

  select row_number() over(order by name) as rowNumber,name,
  ( SELECT a.name from sys.tables t inner join sys.schemas a
ON t.schema_id=a.schema_id
WHERE t.name=ob.name) as schemaname
into #temp from sysobjects ob where xtype='U'

WHILE(@index<@count)
BEGIN
set @schemaname=(SELECT schemaname from #temp where rowNumber=@index)
set @tablename=(SELECT name from #temp where rowNumber=@index)

exec('select * from '+ @schemaname+'.'+@tablename)

set @index=@index+1

END

 

 

通常來說,需要看如下幾個計數器(下面資料參考自http://www.sqlservercentral.com/articles/Miscellaneous/2634/):

  • Memory: Pages/sec
  • Memory: Available Bytes
  • Network Interface: Bytes Total/Sec
  • Physical Disk: % Disk time
  • Physical Disk: Avg. Disk Queue Length
  • Processor: % Processor Time
  • System: Processor Queue Length
  • SQL Server Buffer: Buffer Cache Hit Ratio
  • SQL Server General: User Connections

 

Memory: Pages/sec:最好不要大於5,否則有內存問題

Memory: Available Bytes :這個可以望文生義,不解釋

Network Interface: Bytes Total/Sec :如果這個計數器下降的太快有可能是網絡出現問題

Physical Disk: Avg Disk Queue Length:每個物理盤的等待隊列,大於2有可能是IO瓶頸問題

Physical Disk: % Disk time: 讀/寫活動的百分比,不要大於90%,和上面的計數器一起可以顯示IO瓶頸

Processor: % Processor Time :CPU瓶頸,不要大於90%,大多數情況下,內存和IO瓶頸要更多

System: Processor Queue Length :同樣,和上面計數器一起找出IO瓶頸

SQL Server Buffer: Buffer Cache Hit Ratio :緩存命中率,不要低於85%,否則考慮加內存

SQL Server General:並發數,壓測時快到某一瓶頸看看這個數字,可以作為基准(BaseLine)記下來


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM