1. Trang chủ
  2. » Giáo án - Bài giảng

Bài 11 0 làm việc với chỉ mục

57 478 0

Đ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

Thông tin cơ bản

Định dạng
Số trang 57
Dung lượng 598,5 KB

Nội dung

Index Fragmentation Paul Randal Dev Lead, Microsoft SQL Server Introduction  Structural details of an index  How these structures are used  Index fragmentation  SQL Server 2000 DBCC SHOWCONTIG  SQL Server 2000 DBCC INDEXDEFRAG  "Yukon" dm_db_index_physical_stats  "Yukon" ALTER INDEX Records (1)  How is data stored in SQL Server?  Example record types  Data  Index  Text  Ghost data/index Records (2)  ‘Inside SQL Server 2000’ has the details  Things to note:  Non-leaf index records contain a child page Id in every record  All non-clustered index leaf records contain a base table RID  “Yukon” allows INCLUDE’d columns in an index record Pages (1)  How are records stored?  Example page types  Data page  Index page  Allocation maps (GAM, SGAM, IAM) pages  PFS page Pages (2)  Layout is the same for all page types 8k 96 byte header slot array records free space Extents  How are pages grouped?  Extents are:  A group of 8 contiguous pages  Start on an 8 page boundary  Tracked in IAM, GAM, SGAM pages 0 1 2 3 54 6 7 Heap (1)  Simplest storage arrangement  Comprised entirely of data pages  Unordered, pages unlinked  Records are located using physical RID  create table foo ( first char(100), last char (100), city char (100)) Clustered index (1)  Alternative table structure to heap  Data stored in defined order  Fast lookup through B-tree  Records located through logical RID  create clustered index foo_c on foo (city) Clustered index (2) index tree pages P L L P L L P L L R data pages [...]... logical scan fragmentation Faster and only requires table IS lock Drawback: don’t get the page density Effect of WITH FAST… Option Page count Run Time Default 1, 702 ,889 5 .02 mins WITH FAST 1, 702 ,889 0. 90 mins 5.6 x faster Default 111 ,626,354 WITH FAST 111 ,626,354 382.35 mins 48.73 mins 7.8 x faster Fragmentation calculation R P L P L L P L L L (1) Fragmentation calculation  (2) Reads parent level   Parent... ‘Logical Scan Fragmentation’ ‘Avg Page Density’ – are the pages full? Beware of:   ‘Extent Scan Fragmentation’, ‘Scan Density’ Don’t work over multiple files How to correct fragmentation in SQL Server 200 0?  3 realistic choices     Drop and recreate the index manually Rebuild the index - DBCC DBREINDEX Defrag the index - DBCC INDEXDEFRAG Most people rebuild or defrag Drop/create index  Pros  ... workload for range scans  Learn how to use DBCC SHOWCONTIG  Pick the best method depending on your available downtime Whitepaper on this and more  http://www.microsoft.com/technet/prodtechnol /sql/ 200 0/maintain/ss2kidbp.mspx  Info on identifying which indexes to target Detailed comparison of DBCC DBREINDEX and DBCC INDEXDEFRAG Will be updated for “Yukon”…   . an index  How these structures are used  Index fragmentation  SQL Server 200 0 DBCC SHOWCONTIG  SQL Server 200 0 DBCC INDEXDEFRAG  "Yukon" dm_db_index_physical_stats  "Yukon". unlinked  Records are located using physical RID  create table foo ( first char( 100 ), last char ( 100 ), city char ( 100 )) Clustered index (1)  Alternative table structure to heap  Data stored. Server?  Example record types  Data  Index  Text  Ghost data/index Records (2)  ‘Inside SQL Server 200 0’ has the details  Things to note:  Non-leaf index records contain a child page Id in every

Ngày đăng: 16/06/2014, 13:48

TỪ KHÓA LIÊN QUAN

w