際際滷

際際滷Share a Scribd company logo
Advanced Index Tuning
Brent OzarSQL Server MVPfor Quest SoftwareSQLServerPedia Ed.SQL, SAN, VM adminDot-com-crash experiencePerformance freakTwitter @BrentOBlog: www.BrentOzar.comPhoto Source http://www.flickr.com/photos/vasta/415625308/
Todays AgendaPassive TuningActive TuningIndex CompressionThe Silent KillerResources and Q&A
Passive Tuning with DMVs
DMV Tuning Lifecycle
Removing Indexes
Results
Why Are Writes Different?
Our Table: Items
Indexes On An Item TableIndex #1:UPC_CodeIndex #2:SupplierIDIndex #3:CategoryQtyInStockPhoto licensed with Creative Commons from:http://www.flickr.com/photos/revolute/1944742197/
Data In The Index
But When It 遺鞄温稼乙艶壊
Thats Why
Our Query
A Better Way: IncludesCREATE INDEX IX_Category_Includes  ON dbo.Items (Category)  INCLUDE (QtyInStock)
And When It 遺鞄温稼乙艶壊
Query Plan
Remember, Never SELECT *
Leave a Bread Crumb Trail
DMV Tuning Lifecycle
Missing Index Query
Okay  Now What?
When Do We Add Indexes?
DMV Tuning Lifecycle
Active Tuning: The Wizards
Danger! Danger!
The End ResultCREATE NONCLUSTERED INDEX [_dta_index_Activity_11_1977058079__K1_K4_K7_K5_K3] ON [dbo].[Activity] (	[ServerName] ASC,	[ActivityTypeID] ASC,	[StatusTypeID] ASC,	[StartTime] ASC,	[DatabaseID] ASC)
Rename Each IndexCREATE NONCLUSTERED INDEX [IX_ServerName_ActivityTypeID_StatusTypeID_StartTime_DatabaseID] ON [dbo].[Activity] (	[ServerName] ASC,	[ActivityTypeID] ASC,	[StatusTypeID] ASC,	[StartTime] ASC,	[DatabaseID] ASC) ON [PRIMARY]
Makes Ongoing Tuning Easier
Active Tuning SummaryDont just click applyUse smart namesLook for overlapsGo passive first
SQL 2008 Data Compression
Estimating Compressionsp_estimate_data_compression_savings@schema_name@object_name@index_id@partition_number@data_compression
Index Compression DrawbacksEnterprise Edition onlyNo inheritanceNo automation
The Silent Performance Killer
Pretend Youre SQL ServerPhoto Licensed with Creative Commons From http://www.flickr.com/photos/quacktaculous/3143079032/
13% to 460%Faster
Absolutely No:App changesVendor issuesTesting requiredGuessing on indexesBackfires
Not All Unicorns and RosesStandard Edition: Offline OnlyEnterprise Edition: Most OnlineGenerates a lot of transaction logs
The Native Solution
The Better Way: T-SQL Code
Dont Reinvent The Wheel
http://www.brentozar.com/go/faster

More Related Content

Advanced Index Tuning for SQL Server