the flavors of non-clustered indexes

32
The Flavors of Non - Clustered Indexes

Upload: jason-strate

Post on 28-Nov-2014

538 views

Category:

Technology


6 download

DESCRIPTION

A non-clustered index is just another way to get to data. Add in a couple columns and off you go. Not too much to think about, just fire and forget. But it’s not really that easy. Non-clustered indexes have a number of various ways in which they can be built and designed that can have significant impacts on performance. In this session we’ll look at what can go into a non-clustered index. We will explore what you can put into a non-clustered index and what you can expect back out from performance.

TRANSCRIPT

Page 1: The Flavors of Non-Clustered Indexes

The Flavors of Non-Clustered Indexes

Page 2: The Flavors of Non-Clustered Indexes

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: The Flavors of Non-Clustered Indexes

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: The Flavors of Non-Clustered Indexes

Caution

There will be lots of ice cream pictures

Page 5: The Flavors of Non-Clustered Indexes

Many Flavors

Page 6: The Flavors of Non-Clustered Indexes

http://www.flickr.com/photos/rnljc/5334858173

Page 7: The Flavors of Non-Clustered Indexes

http://www.flickr.com/photos/8566600@N07/2562797853

Page 8: The Flavors of Non-Clustered Indexes

http://www.flickr.com/photos/amayu/5475537796

Page 9: The Flavors of Non-Clustered Indexes

Non-Clustered Indexes

• Sorted key values– One or more columns– Key values only– Pointers to Heap or

Clustered Index rows– Non-LOB data

• Secondary data access– Bridge to the data

• Operations– Index scan– Index seek

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 10: The Flavors of Non-Clustered Indexes

Agenda

Vanilla Sundae Neapolitan

Rocky Road Sugar Cone Gelato

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 11: The Flavors of Non-Clustered Indexes

VANILLA

http://www.flickr.com/photos/cowbite/3452599539/

Page 12: The Flavors of Non-Clustered Indexes

Single Column Index

• Provides a secondary path to data

• Allows alternative paths for finding data

• One column is stored outside table

– Data is sorted by key

– Includes clustered index keys

• Focus on most used columns for filters

• Do not index every column

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 13: The Flavors of Non-Clustered Indexes

SINGLE COLUMN

Demo

http://www.flickr.com/photos/cowbite/3452599539/

Page 14: The Flavors of Non-Clustered Indexes

SUNDAE

Page 15: The Flavors of Non-Clustered Indexes

Index Intersection

• Leverages multiple non-clustered indexes

• Filters on both indexes

• Returns the “intersection” of both indexes

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Index 1

Index 2

Page 16: The Flavors of Non-Clustered Indexes

INDEX INTERSECTION

Demo

Page 17: The Flavors of Non-Clustered Indexes

NEAPOLITAN

Page 18: The Flavors of Non-Clustered Indexes

Multiple Column Index

• Two or more columns in the same index

• Index sorted from left to right

– Cannot skip columns to leverage sort

• Cover filters over multiple columns

– Or cover non-filtered columns

• Reduces number of indexes needed

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 19: The Flavors of Non-Clustered Indexes

MULTIPLE COLUMN

Demo

Page 20: The Flavors of Non-Clustered Indexes

ROCKY ROAD

http://www.flickr.com/photos/stuart_spivack/2069689027/

Page 21: The Flavors of Non-Clustered Indexes

Included Columns

• Additional columns needed for queries

• Typically data not included in index

• Included columns brings in data pages

• Store specific columns unsorted with index

• Don’t included all columns

– Or even most

• Be cautious of update rate of data

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 22: The Flavors of Non-Clustered Indexes

INCLUDED COLUMN

Demo

http://www.flickr.com/photos/stuart_spivack/2069689027/

Page 23: The Flavors of Non-Clustered Indexes

SUGAR CONE

Page 24: The Flavors of Non-Clustered Indexes

Filtered Indexes

• Add a WHERE clause to your index

• Changes the contents of the index

– Reduction in pages

– Reduction in size

– Lessen impact of index scan

• Unmatched Index warning

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 25: The Flavors of Non-Clustered Indexes

FILTERED INDEXES

Demo

Page 26: The Flavors of Non-Clustered Indexes

GELATO

Page 27: The Flavors of Non-Clustered Indexes

Foreign Key Indexes

• All foreign keys should be indexed

– Not an index property

• Constraint leverages sorts on validation

• Can reduce locking, blocking, and deadlocks

• Common problem in many systems

• Silent killer of the database

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 28: The Flavors of Non-Clustered Indexes

FOREIGN KEYS

Page 29: The Flavors of Non-Clustered Indexes

SUMMARY

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 30: The Flavors of Non-Clustered Indexes

Summary

• You can get by on “vanilla” indexes

• Indexes can vary in flavors

• These flavors help improve your databases

• Filtered indexes, included columns, and multiple columns

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 31: The Flavors of Non-Clustered Indexes

Learn More About Indexes

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 32: The Flavors of Non-Clustered Indexes

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