how do non-clustered indexes improve performance?
DESCRIPTION
We've all heard the mantra about the importance of clustered indexes, but what about non-clustered indexes? Do you really need non-clustered indexes or are they just something that consultants recommend to increase their billable hours? In this session, we'll investigate the various flavors of non-clustered indexes and how they can be used to provide significant performance improvements.TRANSCRIPT
How Do Non-Clustered Indexes Improve Performance?
Jason Strate
b: www.jasonstrate.com
t: StrateSQL
Resources jasonstrate.com/go/indexing
Introduction
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
• Industry leaders in Microsoft BI and SQL Server Platform
• SQL Server Professionals - PASS Board of Directors, Speakers, Authors and MVP’s
• National Sales Team Divided by Microsoft Territories
• National System Integrator (NSI)• Gold Certified in Business Intelligence and Data
Platform• Platform Modernization/Safe Passage• Premier Partner for PDW SI Partner Program
MS PDW Partner of Year FY13Frontline Partnership Partner of the Year for Big DataExecutive sponsor - Andy Mouacdie, WW sales director PDW
• Over 7,200 customers worldwide• Over 186,000 people in PW database for demand
generation
About Pragmatic Works
Indexes
The “One” Path
Other Paths…
Agenda
Introduction Just The Cluster
Value of Non-Clustered
Non-Clustered Index Patterns
Summary
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
CLUSTERED INDEX OR HEAP
IntroductionJust The Cluster
Value of Non-
Clustered
Non-Clustered
Index Patterns
Summary
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
JUST THE CLUSTER
IntroductionJust The Cluster
Value of Non-
Clustered
Non-Clustered
Index Patterns
Summary
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
Clustered
• Default data storage
• Sorted data storage– One or more columns
– Data and index stored together
• Fragmentation
• Operations– Clustered index scan
– Clustered index seek
– Key Lookup
The Clustered Index Problem
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
The Clustered Index Problem
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
What About Non-Key Columns?
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
What About Non-Key Columns?
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
What About Non-Key Columns?
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
CLUSTERED INDEX PROBLEMDemo
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
Left searching for answers…
Got Problems?
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
• Locks
– Lock Escalation
– Blocking
– Deadlocking
• Resource
– CPU
– Memory
– Storage
VALUE OF NON-CLUSTERED
IntroductionJust The Cluster
Value of Non-
Clustered
Non-Clustered
Index Patterns
Summary
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
• Sorted key values–One or more columns
–Key values only
–Pointers to Heap/ClusteredIndex rows
• Secondary data access– Bridge to the data
• Operations– Index scan– Index seek
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
Additional Index Magic
• Included Columns
– Add data pages to index
– Bring in the data pages!
• Filtered Indexes
– Reduce the index pages
• Data Compression
– Row/Page
– Reduce the index pages
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
The Non-Clustered
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
What About Non-Key Columns?
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
SELECT ProductID, OrderQty
FROM Sales.SalesOrderheader
WHERE ProductID = 776
What About Non-Key Columns?
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
SELECT ProductID, OrderQty
FROM Sales.SalesOrderheader
WHERE ProductID = 716
What About Non-Key Columns?
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
SELECT ProductID, OrderQty
FROM Sales.SalesOrderheader
WHERE ProductID = 762
NON-CLUSTERED INDEX PATTERNS
IntroductionJust The Cluster
Value of Non-
Clustered
Non-Clustered
Index Patterns
Summary
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
Non-Clustered Index Patterns
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
Cover Up
Look Up
Team Up
Non-Clustered Index Patterns
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
Cover Up
Look Up
Team Up
Non-Clustered Indexes - Cover Up
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
CREATE INDEX IX_Sample ON
Sales.SalesOrderheader (ProductID)
Non-Clustered Indexes - Cover Up
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
SELECT ProductID
FROM Sales.SalesOrderheader
WHERE ProductID = 776
Non-Clustered Indexes - Cover Up
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
SELECT ProductID
FROM Sales.SalesOrderheader
Non-Clustered Indexes - Cover Up
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
CREATE INDEX IX_Sample ON
Sales.SalesOrderheader (ProductID
,OrderQty)
Non-Clustered Indexes - Cover Up
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
SELECT ProductID, OrderQty
FROM Sales.SalesOrderheader
WHERE ProductID = 716
Non-Clustered Indexes - Cover Up
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
SELECT ProductID, OrderQty
FROM Sales.SalesOrderheader
Non-Clustered Index Patterns
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
Cover Up
Look Up
Team Up
Non-Clustered Indexes – Look Up
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
CREATE INDEX IX_Sample ON
Sales.SalesOrderheader (ProductID)
Non-Clustered Indexes – Look Up
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
SELECT ProductID, CarrierTrackingNumber
FROM Sales.SalesOrderheader
WHERE ProductID = 776
Non-Clustered Indexes – Look Up
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
SELECT ProductID, CarrierTrackingNumber
FROM Sales.SalesOrderheader
WHERE ProductID = 776
Non-Clustered Index Patterns
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
Cover Up
Look Up
Team Up
Non-Clustered Indexes – Team Up
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
CREATE INDEX IX_Sample ON
Sales.SalesOrderheader (ProductID)
Non-Clustered Indexes – Team Up
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
CREATE INDEX IX_Sample ON
Sales.SalesOrderheader
(CarrierTrackingNumber)
Non-Clustered Indexes – Team Up
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
SELECT ProductID, CarrierTrackingNumber
FROM Sales.SalesOrderheader
WHERE ProductID = 776
AND CarrierTrackingNumber = ‘4911-403C-98’
Non-Clustered Indexes – Team Up
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
SELECT ProductID, CarrierTrackingNumber
FROM Sales.SalesOrderheader
WHERE ProductID = 776
AND CarrierTrackingNumber = ‘4911-403C-98’
NON-CLUSTERED INDEX PATTERNDemo
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
SUMMARY
IntroductionJust The Cluster
Value of Non-
Clustered
Non-Clustered
Index Patterns
Summary
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
Summary
1. Clustered indexes are not enough
2. Non-clustered indexes provide additional paths
3. Learn how to leverage all of the properties
4. Performance and stability enhanced through non-clustered indexes
5. Don’t go overboard… too much of a good thing
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
Learn More About Indexes
MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
ServicesSpeed development through training, and rapid development services from Pragmatic Works.
ProductsBI products to covert to a Microsoft BI platform and simplify development onthe platform.
FoundationHelping those who do not have themeans to get into information technologyachieve their dreams.
For more information…
Name: Jason Strate
Email: [email protected]
Blog: www.jasonstrate.com
Resource: jasonstrate.com/go/indexing