Bài giảng Client/Server - Chương 11: Flag (Phần 1) pdf

17 249 0
Bài giảng Client/Server - Chương 11: Flag (Phần 1) pdf

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Clustered index (1)  Alternative table structure to heap  Data stored in defined order  Fast lookup through B-tree  Records located through logical RID create table foo ( first char(100), last char (100), city char (100)) create clustered index foo_c on foo (city)   Clustered index (2) R index tree pages P L P L L P L L L data pages Non-clustered index (1)  A way to provide a different ordering  Define on heaps or clustered indexes  Leaf records contain RID of matching record in base table  create index foo_nc on foo (last) create index foo_nc on foo (last) include (first)  Non-clustered index (2) R index tree pages P L P L L P L L L index leaf pages Why use an index?  Allows a variety of access modes:     Singleton lookup Range scan Allocation order scan Allows skipping of sort step in query Singleton lookup Matching record Range scan Allocation-order scan What causes fragmentation Index leaf level of newly built index Red arrow is the allocation order Black arrows are following the logical order (1) What causes fragmentation Newly built index leaf after a single page split Red arrow is the allocation order Black arrows are following the logical order (2) What causes fragmentation Index leaf level after random inserts/deletes Red arrow is the allocation order Black arrows are following the logical order (3) Logical scan fragmentation  Occurs when the next logical page is not the next physical page Extent scan fragmentation  Occurs when the extents in an index are not contiguous Index A Index B Index A Index B Index A Index A Inside INDEXDEFRAG  (1) Stage 1: Page compaction     Make pages have ‘fullness’ near to original FILLFACTOR Operates on leaf level only Compacts pages by shuffling rows towards left side of the B-tree Delete pages made empty Inside INDEXDEFRAG Page compaction example (2) Inside INDEXDEFRAG  (3) Stage 2: Page defragment   Make logical order same as allocation order Operates on leaf level only Inside INDEXDEFRAG (4) Page reordering example AB VW BC WZ DE JK JK KL EF KL AB JK AB BC KL BC VW DE DE WZ EF EF 1 2 3 4 VW WZ 2104 2104 Physical Page ID Physical Page ID 17 ...Clustered index (2) R index tree pages P L P L L P L L L data pages Non-clustered index (1)  A way to provide a different ordering  Define on heaps or clustered indexes  Leaf... Range scan Allocation-order scan What causes fragmentation Index leaf level of newly built index Red arrow is the allocation order Black arrows are following the logical order (1) What causes fragmentation... INDEXDEFRAG  (1) Stage 1: Page compaction     Make pages have ‘fullness’ near to original FILLFACTOR Operates on leaf level only Compacts pages by shuffling rows towards left side of the B-tree Delete

Ngày đăng: 27/06/2014, 03:20

Từ khóa liên quan

Mục lục

  • Clustered index (1)

  • Clustered index (2)

  • Non-clustered index (1)

  • Non-clustered index (2)

  • Why use an index?

  • Singleton lookup

  • Range scan

  • Allocation-order scan

  • What causes fragmentation (1)

  • What causes fragmentation (2)

  • What causes fragmentation (3)

  • Logical scan fragmentation

  • Extent scan fragmentation

  • Inside INDEXDEFRAG (1)

  • Inside INDEXDEFRAG (2)

  • Inside INDEXDEFRAG (3)

  • Inside INDEXDEFRAG (4)

Tài liệu cùng người dùng

Tài liệu liên quan