how do non-clustered indexes improve performance?

49
How Do Non - Clustered Indexes Improve Performance?

Upload: jason-strate

Post on 17-Jun-2015

1.319 views

Category:

Technology


1 download

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

Page 1: How Do Non-Clustered Indexes Improve Performance?

How Do Non-Clustered Indexes Improve Performance?

Page 2: How Do Non-Clustered Indexes Improve Performance?

Jason Strate

e: [email protected]

e: [email protected]

b: www.jasonstrate.com

t: StrateSQL

Resources jasonstrate.com/go/indexing

Introduction

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 3: How Do Non-Clustered Indexes Improve Performance?

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

Page 4: How Do Non-Clustered Indexes Improve Performance?

Indexes

Page 5: How Do Non-Clustered Indexes Improve Performance?

The “One” Path

Page 6: How Do Non-Clustered Indexes Improve Performance?

Other Paths…

Page 7: How Do Non-Clustered Indexes Improve Performance?
Page 8: How Do Non-Clustered Indexes Improve Performance?

Agenda

Introduction Just The Cluster

Value of Non-Clustered

Non-Clustered Index Patterns

Summary

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 9: How Do Non-Clustered Indexes Improve Performance?

CLUSTERED INDEX OR HEAP

IntroductionJust The Cluster

Value of Non-

Clustered

Non-Clustered

Index Patterns

Summary

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 10: How Do Non-Clustered Indexes Improve Performance?

JUST THE CLUSTER

IntroductionJust The Cluster

Value of Non-

Clustered

Non-Clustered

Index Patterns

Summary

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 11: How Do Non-Clustered Indexes Improve Performance?

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

Page 12: How Do Non-Clustered Indexes Improve Performance?

The Clustered Index Problem

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 13: How Do Non-Clustered Indexes Improve Performance?

The Clustered Index Problem

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 14: How Do Non-Clustered Indexes Improve Performance?

What About Non-Key Columns?

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 15: How Do Non-Clustered Indexes Improve Performance?

What About Non-Key Columns?

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 16: How Do Non-Clustered Indexes Improve Performance?

What About Non-Key Columns?

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 17: How Do Non-Clustered Indexes Improve Performance?

CLUSTERED INDEX PROBLEMDemo

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 18: How Do Non-Clustered Indexes Improve Performance?

Left searching for answers…

Page 19: How Do Non-Clustered Indexes Improve Performance?

Got Problems?

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

• Locks

– Lock Escalation

– Blocking

– Deadlocking

• Resource

– CPU

– Memory

– Storage

Page 20: How Do Non-Clustered Indexes Improve Performance?

VALUE OF NON-CLUSTERED

IntroductionJust The Cluster

Value of Non-

Clustered

Non-Clustered

Index Patterns

Summary

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 21: How Do Non-Clustered Indexes Improve Performance?

• 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

Page 22: How Do Non-Clustered Indexes Improve Performance?

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

Page 23: How Do Non-Clustered Indexes Improve Performance?

The Non-Clustered

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 24: How Do Non-Clustered Indexes Improve Performance?

What About Non-Key Columns?

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

SELECT ProductID, OrderQty

FROM Sales.SalesOrderheader

WHERE ProductID = 776

Page 25: How Do Non-Clustered Indexes Improve Performance?

What About Non-Key Columns?

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

SELECT ProductID, OrderQty

FROM Sales.SalesOrderheader

WHERE ProductID = 716

Page 26: How Do Non-Clustered Indexes Improve Performance?

What About Non-Key Columns?

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

SELECT ProductID, OrderQty

FROM Sales.SalesOrderheader

WHERE ProductID = 762

Page 27: How Do Non-Clustered Indexes Improve Performance?

NON-CLUSTERED INDEX PATTERNS

IntroductionJust The Cluster

Value of Non-

Clustered

Non-Clustered

Index Patterns

Summary

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 28: How Do Non-Clustered Indexes Improve Performance?

Non-Clustered Index Patterns

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Cover Up

Look Up

Team Up

Page 29: How Do Non-Clustered Indexes Improve Performance?

Non-Clustered Index Patterns

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Cover Up

Look Up

Team Up

Page 30: How Do Non-Clustered Indexes Improve Performance?

Non-Clustered Indexes - Cover Up

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

CREATE INDEX IX_Sample ON

Sales.SalesOrderheader (ProductID)

Page 31: How Do Non-Clustered Indexes Improve Performance?

Non-Clustered Indexes - Cover Up

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

SELECT ProductID

FROM Sales.SalesOrderheader

WHERE ProductID = 776

Page 32: How Do Non-Clustered Indexes Improve Performance?

Non-Clustered Indexes - Cover Up

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

SELECT ProductID

FROM Sales.SalesOrderheader

Page 33: How Do Non-Clustered Indexes Improve Performance?

Non-Clustered Indexes - Cover Up

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

CREATE INDEX IX_Sample ON

Sales.SalesOrderheader (ProductID

,OrderQty)

Page 34: How Do Non-Clustered Indexes Improve Performance?

Non-Clustered Indexes - Cover Up

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

SELECT ProductID, OrderQty

FROM Sales.SalesOrderheader

WHERE ProductID = 716

Page 35: How Do Non-Clustered Indexes Improve Performance?

Non-Clustered Indexes - Cover Up

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

SELECT ProductID, OrderQty

FROM Sales.SalesOrderheader

Page 36: How Do Non-Clustered Indexes Improve Performance?

Non-Clustered Index Patterns

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Cover Up

Look Up

Team Up

Page 37: How Do Non-Clustered Indexes Improve Performance?

Non-Clustered Indexes – Look Up

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

CREATE INDEX IX_Sample ON

Sales.SalesOrderheader (ProductID)

Page 38: How Do Non-Clustered Indexes Improve Performance?

Non-Clustered Indexes – Look Up

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

SELECT ProductID, CarrierTrackingNumber

FROM Sales.SalesOrderheader

WHERE ProductID = 776

Page 39: How Do Non-Clustered Indexes Improve Performance?

Non-Clustered Indexes – Look Up

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

SELECT ProductID, CarrierTrackingNumber

FROM Sales.SalesOrderheader

WHERE ProductID = 776

Page 40: How Do Non-Clustered Indexes Improve Performance?

Non-Clustered Index Patterns

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Cover Up

Look Up

Team Up

Page 41: How Do Non-Clustered Indexes Improve Performance?

Non-Clustered Indexes – Team Up

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

CREATE INDEX IX_Sample ON

Sales.SalesOrderheader (ProductID)

Page 42: How Do Non-Clustered Indexes Improve Performance?

Non-Clustered Indexes – Team Up

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

CREATE INDEX IX_Sample ON

Sales.SalesOrderheader

(CarrierTrackingNumber)

Page 43: How Do Non-Clustered Indexes Improve Performance?

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’

Page 44: How Do Non-Clustered Indexes Improve Performance?

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’

Page 45: How Do Non-Clustered Indexes Improve Performance?

NON-CLUSTERED INDEX PATTERNDemo

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 46: How Do Non-Clustered Indexes Improve Performance?

SUMMARY

IntroductionJust The Cluster

Value of Non-

Clustered

Non-Clustered

Index Patterns

Summary

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 47: How Do Non-Clustered Indexes Improve Performance?

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

Page 48: How Do Non-Clustered Indexes Improve Performance?

Learn More About Indexes

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 49: How Do Non-Clustered Indexes Improve Performance?

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