sqlserver效能調優常用方法

來源:互聯網
上載者:User

標籤:

1.檢查資料庫空間使用方式,查看哪些表佔用了比較大的磁碟空間

執行語句如下:

select o.name,        SUM(p.reserved_page_count) as reserved_page_count,        SUM(p.used_page_count) as used_page_count,        SUM(        case        when(p.index_id<2) then (p.in_row_data_page_count+        p.lob_used_page_count+p.row_overflow_used_page_count)        else p.lob_used_page_count+p.row_overflow_used_page_count        end        ) as DataPages,        SUM(        case        when (p.index_id<2) then row_count        else 0        end        ) as rowCounts        from sys.dm_db_partition_stats p inner join sys.objects o        on p.object_id=o.object_id        group by o.name        order by rowCounts desc
View Code

 

2.通過活動監視器查看效能消耗

通過磁碟IO,CPU佔用時間,邏輯讀寫的次數來判斷哪些語句消耗效能比較大

 

3.通過執行時間,磁碟IO和執行計畫查看sql語句情況,包括編譯執行時間,索引掃描尋找,讀寫等等

查看sql語句的執行時間和表掃描,邏輯讀寫情況的語句:

SET STATISTICS TIME ON
SET STATISTICS IO ON

 

sqlserver效能調優常用方法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.