SQL Server Index and Partition Strategy
-
Upload
hamid-j-fard -
Category
Data & Analytics
-
view
251 -
download
4
Transcript of SQL Server Index and Partition Strategy
Index and Partition Strategy
By: Hamid J. Fard (Data Platform Specialist)
Session Outlines:What an Index is.The benefits and overhead of an Index.General recommendation for index design.Recommendation for Clustered and non-
Clustered Index.Index on Partitioned Table
What is an Index?An object in SQL Server Database.Affects I/O Physical and Logical Operations.Affects to Performance of Retrieving Data.There are Two Types of Index.It might Change the Table Structure.Contains Several Levels.
The Benefit of IndexesClustered Index Improves Modification
PerformanceClustered Index Changes the Table StructureClustered Index Sort the Data PhysicallyNon-Clustered Index Improves Query
PerformanceNon-Clustered Index Points at RID or Clustered
IndexNon-Clustered Index can be Stored on Different
I/O Path to Improve the I/O Performance
The Benefit of Indexes (Cont.)Consider single column table with 27 rows.
Initial Layout of 27 Rows
Ordered Layout of 27 Rows
B-Tree Layout of 27 Rows
Index OverheadTable with Index needs more Storage and
MemoryData Manipulation Queries (CRUD) Take LongerMore Processing Time Required to Maintain the
Indexes of Constantly Changing TablesClustered Index has Greater OverheadSQL Server supplies some DMVs for Monitoring
Index Performance and Detail Informationsys.dm_db_index_operational_stats (Low-Level Information)
sys.dm_db_index_usage_stats (Returns Statistics)
Index Design RecommendationExamine the Where and Join criteria clauseUse Narrow IndexesExamine Column UniquenessExamine the Column Data TypeConsider Column OrderConsider the Type of Index (Clustered vs.
NonClustered)
Use Narrow IndexAvoid Wide Data Type such as
CHAR, VARCHAR, NCHAR, NVARCHAR
It can Accumulate more Rows in 8KB Index Page.
Reduces Storage space for Database
Reduces the I/O Operations.
Clustered Index RecommendationsCreate Clustered Index First.Keep the Index Key Narrow.Rebuild the Clustered Index in Single Step.Create Clustered Index with Preorder Sort.Do not Create Clustered Index on Frequently
Updatable Column.Do not Use Wide Key.Prevent Too Many Concurrent Inserts in
Sequential Order.
Non-Clustered Index RecommendationCan be Used with Wide Key.It Can be on Frequently Updatable Columns.Can be Filtered.Can be Used in Join or Where Criteria Clause.Can be on Low Selectivity Column.
Covering IndexesIt can Improve the Query Performance.It Stores the Covering Columns Next to the RID.It does not Required to Read the Base Table.Reduces I/O Operations.Reduces Execution Time.
Index CompressionIntroduced in SQL Server 2008.Available only in Enterprise and Developer
Edition.This can lead to Serious Performance
Improvement.There will be an Overhead of CPU and Memory.Non-Leaf Pages in an Index Receive no
Compression under the Page Type.
Index on Partitioned TableDifferent index will be created on every partition.Each index can be rebuilt or reorganized
separately.It boost up the CRUD operations performance.SQL Server can manage every index separately
on every partition.
DemoCreate Partition TableRetrieve Specific Partition’s Record.Create Index on every Partition.Rebuild the Index on Specific Partition.
Questions and Answers
?(15 Minutes)