Fragmentation

2019-10-21  本文已影响0人  鲸鱼酱375

2.Fragmentation & Maintenance

2.1 What is Fragmentation?

2.2 Types of Fragmentation

2.2.1 Internal Fragmentation (memory bubbles)

If a leaf level page in an index is not filled completely or to its capacity, it is called a memory bubble or internal fragmentation. When there are some DML operations on the table with indexes, SQL Server has to split the page or reassign a new page (based on type of DML) to make sure that the data is sorted as per the indexing column, that causes internal fragmentation.

internal

2.2.2 External Fragmentation

When the logical order of the data doesn't match with physical order of the data. That is the data in the pages are not in sequence. Page split is one of the reasons along with unavailability of immediate page for data load.

external external

2.3 Find Fragmentation Levels

2.3.1 GUI

2.3.2 DB Console Command

2.3.3 Dynamic Management Views

sys.dm_db_index_physical_stats ( 
    { database_id | NULL | 0 | DEFAULT }
  , { object_id | NULL | 0 | DEFAULT }
  , { index_id | NULL | 0 | -1 | DEFAULT }
  , { partition_number | NULL | 0 | DEFAULT }
  , { mode | NULL | DEFAULT }
)

2.4 Maintenance on Indexes

2.4.1 Reorganize

2.4.2 Rebuild

reorganize 就是把memeor bubble挤走, rebuild就是把page重新排序

2.5 Additional Options for Rebuild

2.5.1 Fillfactor

2.5.2 Pad_Index

2.5.3 Online

https://docs.microsoft.com/en-us/sql/relational-databases/indexes/guidelines-for-online-index-operations?view=sql-server-2017

2.5.4 Statistics_Norecompute

2.5.6 Sort_In_TempDB

2.6 note

上一篇 下一篇

猜你喜欢

热点阅读