天天看點

人人都是 DBA(XIII)索引資訊收集腳本彙編

什麼?有個 SQL 執行了 8 秒!

哪裡出了問題?臣妾不知道啊,得找 DBA 啊。

DBA 人呢?離職了!!擦!!!

程式員在無處尋求幫助時,就得想辦法自救,努力讓自己變成 "僞 DBA"。

<a href="http://www.cnblogs.com/gaochundong/p/everyone_is_a_dba_index_info_collection.html#find_missing_indexes_by_index_advantage">找出哪些表的 Index 需要改進</a>

<a href="http://www.cnblogs.com/gaochundong/p/everyone_is_a_dba_index_info_collection.html#find_missing_indexes_for_current_db_by_index_advantage">在指定資料庫中查找哪些表的 Index 需要改進</a>

<a href="http://www.cnblogs.com/gaochundong/p/everyone_is_a_dba_index_info_collection.html#find_missing_index_warnings_for_cached_plans">根據緩存的查詢計劃判斷 SP 是否需要優化</a>

<a href="http://www.cnblogs.com/gaochundong/p/everyone_is_a_dba_index_info_collection.html#find_index_high_writes_and_less_reads">發現那些 Index 的寫遠多于讀的表 </a>

<a href="http://www.cnblogs.com/gaochundong/p/everyone_is_a_dba_index_info_collection.html#when_index_statistics_update_last_time">檢視 Index 的 Statistics 最後更新時間</a>

<a href="http://www.cnblogs.com/gaochundong/p/everyone_is_a_dba_index_info_collection.html#look_at_most_frequently_modified_indexes">檢視哪些 Index 被修改的最頻繁</a>

<a href="http://www.cnblogs.com/gaochundong/p/everyone_is_a_dba_index_info_collection.html#get_index_fragmentation_info">檢視 Index 碎片化指數</a>

<a href="http://www.cnblogs.com/gaochundong/p/everyone_is_a_dba_index_info_collection.html#show_overall_index_usage_of_reads">哪個 Index 上的讀操作最活躍</a>

<a href="http://www.cnblogs.com/gaochundong/p/everyone_is_a_dba_index_info_collection.html#show_index_overall_usage_by_writes">哪個 Index 上的寫操作最活躍</a>

<a href="http://www.cnblogs.com/gaochundong/p/everyone_is_a_dba_index_info_collection.html#get_index_used_buffer_page_count">檢視 Index 所使用的 Buffer 數量</a>

<a href="http://www.cnblogs.com/gaochundong/p/everyone_is_a_dba_index_info_collection.html#get_index_page_io_latch_waits">按照 IO Latch 等待請求對索引進行排行</a>

<a></a>

人人都是 DBA(XIII)索引資訊收集腳本彙編

這裡查詢出的資料,隻是說明資料尋址時間有點兒長,不一定就是缺少索引所引起的。

人人都是 DBA(XIII)索引資訊收集腳本彙編
人人都是 DBA(XIII)索引資訊收集腳本彙編
人人都是 DBA(XIII)索引資訊收集腳本彙編

由于對索引的寫操作遠多于讀操作,看起來 Index 的幫助不大,但需要根據業務需求來判斷是否能夠 Drop 掉該索引。

人人都是 DBA(XIII)索引資訊收集腳本彙編

參考資料:

<a href="http://msdn.microsoft.com/en-us/library/ms190397.aspx" target="_blank">Statistics</a>

<a href="http://msdn.microsoft.com/en-us/library/ms187348.aspx" target="_blank">UPDATE STATISTICS (Transact-SQL)</a>

<a href="http://msdn.microsoft.com/en-us/library/ms173804.aspx" target="_blank">sp_updatestats (Transact-SQL)</a>

<a href="http://sqlblog.com/blogs/ben_nevarez/archive/2009/10/06/rebuilding-indexes-vs-updating-statistics.aspx" target="_blank">Rebuilding Indexes vs. Updating Statistics</a>

<a href="http://dba.stackexchange.com/questions/48991/does-a-re-index-update-statistics" target="_blank">Does a re-index update statistics?</a>

<a href="https://ola.hallengren.com/sql-server-index-and-statistics-maintenance.html" target="_blank">SQL Server Index and Statistics Maintenance</a>

SQL Server 2008 R2

人人都是 DBA(XIII)索引資訊收集腳本彙編

The user_updates counter indicates the level of maintenance on the index caused by insert, update, or delete operations on the underlying table or view.

SQL Server 2012

人人都是 DBA(XIII)索引資訊收集腳本彙編

<a href="http://www.brentozar.com/archive/2012/08/sql-server-index-fragmentation/" target="_blank">Stop Worrying About SQL Server Fragmentation</a>

<a href="http://www.sqlskills.com/blogs/paul/importance-of-index-maintenance/" target="_blank">Importance of index maintenance</a>

<a href="http://msdn.microsoft.com/en-us/library/ms189858.aspx" target="_blank">Reorganize and Rebuild Indexes</a>

<a href="http://www.mssqltips.com/sql-server-tip-category/39/fragmentation-and-index-maintenance/" target="_blank">Fragmentation and Index Maintenance Tips</a>

<a href="http://blogs.technet.com/b/sql_server_isv/archive/2010/10/18/index-fragmentation-if-it-isn-t-broke-don-t-fix-it.aspx" target="_blank">Index Fragmentation–"If it isn’t broken, don’t fix it"</a>

人人都是 DBA(XIII)索引資訊收集腳本彙編
人人都是 DBA(XIII)索引資訊收集腳本彙編
人人都是 DBA(XIII)索引資訊收集腳本彙編
人人都是 DBA(XIII)索引資訊收集腳本彙編

《人人都是 DBA》系列文章索引:

 序号 

 名稱 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

本文轉自匠心十年部落格園部落格,原文連結:http://www.cnblogs.com/gaochundong/p/everyone_is_a_dba_index_info_collection.html,如需轉載請自行聯系原作者