How Do Non-Clustered
Indexes Improve Performance?
Introduction
Jason
Strate

e: jstrate@pragmaticworks.com
e: jasonstrate@gmail.com
b: www.jasonstrate.com

t: StrateSQL

Resources

jasonstrate.com/go/indexing

MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
About Pragmatic Works

•
•
•
•
•
•
•

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 FY13
Frontline Partnership Partner of the Year for Big Data
Executive sponsor - Andy Mouacdie, WW sales director
PDW

•
•

Over 7,200 customers worldwide
Over 186,000 people in PW database for demand
generation
MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
Indexes
The ā€œOneā€ Path
Other Paths…
Agenda

Introduction

Just The
Cluster

Non-Clustered
Index Patterns
MAKING BUSINESS INTELLIGENT

Value of NonClustered

Summary
www.pragmaticworks.com
Introduction

Just The
Cluster

Value of
NonClustered

NonClustered
Index
Patterns

Summary

CLUSTERED INDEX OR HEAP

MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
Introduction

Just The
Cluster

Value of
NonClustered

NonClustered
Index
Patterns

Summary

JUST THE CLUSTER

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
Demo

CLUSTERED INDEX PROBLEM

MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
Left searching for answers…
Got Problems?
• Locks
– Lock Escalation
– Blocking
– Deadlocking

• Resource
– CPU
– Memory
– Storage
MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
Introduction

Just The
Cluster

Value of
NonClustered

NonClustered
Index
Patterns

Summary

VALUE OF NON-CLUSTERED

MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
• Sorted key values
–One or more columns
–Key values only
–Pointers to Heap/Clustered
Index 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?

SELECT ProductID, OrderQty
FROM Sales.SalesOrderheader
WHERE ProductID = 776
MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
What About Non-Key Columns?

SELECT ProductID, OrderQty
FROM Sales.SalesOrderheader
WHERE ProductID = 716
MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
What About Non-Key Columns?

SELECT ProductID, OrderQty
FROM Sales.SalesOrderheader
WHERE ProductID = 762
MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
Introduction

Just The
Cluster

Value of
NonClustered

NonClustered
Index
Patterns

Summary

NON-CLUSTERED INDEX PATTERNS

MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
Non-Clustered Index Patterns
Cover
Up

Team
Up
MAKING BUSINESS INTELLIGENT

Look
Up
www.pragmaticworks.com
Non-Clustered Index Patterns
Cover
Up

Team
Up
MAKING BUSINESS INTELLIGENT

Look
Up
www.pragmaticworks.com
Non-Clustered Indexes - Cover Up

CREATE INDEX IX_Sample ON
Sales.SalesOrderheader (ProductID)

MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
Non-Clustered Indexes - Cover Up

SELECT ProductID
FROM Sales.SalesOrderheader
WHERE ProductID = 776
MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
Non-Clustered Indexes - Cover Up

SELECT ProductID
FROM Sales.SalesOrderheader

MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
Non-Clustered Indexes - Cover Up

CREATE INDEX IX_Sample ON
Sales.SalesOrderheader (ProductID
,OrderQty)
MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
Non-Clustered Indexes - Cover Up

SELECT ProductID, OrderQty
FROM Sales.SalesOrderheader
WHERE ProductID = 716
MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
Non-Clustered Indexes - Cover Up

SELECT ProductID, OrderQty
FROM Sales.SalesOrderheader

MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
Non-Clustered Index Patterns
Cover
Up

Team
Up
MAKING BUSINESS INTELLIGENT

Look
Up
www.pragmaticworks.com
Non-Clustered Indexes – Look Up

CREATE INDEX IX_Sample ON
Sales.SalesOrderheader (ProductID)

MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
Non-Clustered Indexes – Look Up

SELECT ProductID, CarrierTrackingNumber
FROM Sales.SalesOrderheader
WHERE ProductID = 776
MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
Non-Clustered Indexes – Look Up

SELECT ProductID, CarrierTrackingNumber
FROM Sales.SalesOrderheader
WHERE ProductID = 776
MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
Non-Clustered Index Patterns
Cover
Up

Team
Up
MAKING BUSINESS INTELLIGENT

Look
Up
www.pragmaticworks.com
Non-Clustered Indexes – Team Up

CREATE INDEX IX_Sample ON
Sales.SalesOrderheader (ProductID)

MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
Non-Clustered Indexes – Team Up

CREATE INDEX IX_Sample ON
Sales.SalesOrderheader
(CarrierTrackingNumber)
MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
Non-Clustered Indexes – Team Up

SELECT ProductID, CarrierTrackingNumber
FROM Sales.SalesOrderheader
WHERE ProductID = 776
AND CarrierTrackingNumber = ā€˜4911-403C-98’

MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
Non-Clustered Indexes – Team Up

SELECT ProductID, CarrierTrackingNumber
FROM Sales.SalesOrderheader
WHERE ProductID = 776
AND CarrierTrackingNumber = ā€˜4911-403C-98’

MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
Demo

NON-CLUSTERED INDEX PATTERN

MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
Introduction

Just The
Cluster

Value of
NonClustered

NonClustered
Index
Patterns

Summary

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
For more information…
Name: Jason Strate

Email: jstrate@pragmaticworks.com
Blog: www.jasonstrate.com
Resource: jasonstrate.com/go/indexing

Products
BI products to covert to a Microsoft BI
platform and simplify development on
the platform.

Services
Speed development through training, and
rapid development services from
Pragmatic Works.

Foundation
Helping those who do not have the
means to get into information technology
achieve their dreams.

How Do Non-Clustered Indexes Improve Performance?