Presentation is loading. Please wait.

Presentation is loading. Please wait.

Indexing Fundamentals

Similar presentations


Presentation on theme: "Indexing Fundamentals"— Presentation transcript:

1 Indexing Fundamentals
Kathi Kellenberger Kellenberger Consulting, LLC

2 Who am I? Teacher Author @auntkathi http://auntkathisql.com
Beginning T-SQL Expert T-SQL Window Functions Beginning SSRS Consultant @auntkathi

3 The problem…. Our application is slow, and we don’t know why.
We are seeing lots of timeouts. There is something wrong with our SQL Server; it used to be fast. We have indexes, but we don’t know if they are the right ones.

4 What they have tried Added processors Upgraded storage
Added random indexes

5 Make SQL Server work less
Table

6 Make SQL Server work less
Index

7 Find My Number Game

8 Two types of tables Heaps Clustered Indexes

9 Heaps M S D X A T A

10 Clustered Index M D T A S X A D M S T X

11 Clustered Index M Non-Leaf Levels D T Contain the key A S X Leaf Level
Contains the key other columns, and possibly a Uniquifier

12 Clustered Indexes Best Practices
Narrow Unique Never changing Incrementing* Based on workload *Subject to debate

13 Two types of indexes Clustered Index Nonclustered Index

14 Nonclustered Index M Non-Leaf Levels D T Contain the key A S X
Contains the key, Pointer to the table row, and included columns

15 Pointer to table row Clustered index – Cluster Key
Heap – RID (row identifier)

16 Column order LastName FirstName City

17 Covering index

18 SARGability

19 SARGability Causes Function applied to column
LIKE with leading wildcard (%) NOT LIKE No filter on leading column Implicit conversions

20 Nonclustered Index Best Practices
Can add up to 999, but try to stay at 10 or less indexes per table Foreign keys Common WHERE clause columns Use workload to tune Filter before joining columns Take advantage of included columns


Download ppt "Indexing Fundamentals"

Similar presentations


Ads by Google