5 ways to improve performance through indexing

1,103 views

Published on

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,103
On SlideShare
0
From Embeds
0
Number of Embeds
479
Actions
Shares
0
Downloads
32
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

5 ways to improve performance through indexing

  1. 1. 5 Ways to Improve Performance through Indexing
  2. 2. Jason Strate e: jstrate@pragmaticworks.com e: jasonstrate@gmail.com b: www.jasonstrate.com t: StrateSQL Resources jasonstrate.com/go/indexing Introduction MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  3. 3. MAKING BUSINESS INTELLIGENT www.pragmaticworks.com • Founded 2008 by MSFT MVP Brian Knight • Focused on the MSFT SQL Server Platform • Provides services, training and software • MSFT/HP “go to” partner: • Gold Certified: o BI o Data Management o SQL Performance • Team led by multiple MVP’s • Offices throughout the US with Corporate HQ in Jacksonville, FL Pragmatic Works Company History
  4. 4. Indexes
  5. 5. Disappointment
  6. 6. 5 Ways to Improve Performance through Indexing
  7. 7. Lookup Imbalance
  8. 8. Lookup Imbalance • Excessive key lookups – Exceed number of seeks • Problems – Increased CPU – Increased IO – Increased duration MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  9. 9. Possible Solutions • Ignore the problem – Choose high key lookup rate • Move clustered index – Maybe the key is wrong • Add included columns – Improve NC indexes MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  10. 10. Case Study 1 • What’s wrong? • Do you see the pattern? • What do you do? – Move clustered index MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  11. 11. Case Study 2 • What’s wrong? • Do you see the pattern? • What do you do? – Move clustered index – Add included columns MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  12. 12. Case Study 3 • What’s wrong? • Do you see the pattern? • What do you do? – Add included columns MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  13. 13. November 6-9, Seattle, WA Lookup Imbalance • Demo MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  14. 14. Lookup Imbalance Summary • Key lookups should not exceed seeks • Investigate “WHY” when they do • Consider whether to: – Move the clustered index – Add included columns to non-clustered indexes • Usage patterns will shift over time MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  15. 15. Scan Heavy Indexes
  16. 16. Scan Heavy Indexes • High scans on large indexes – Exceed seeks • Problems – Increased IO – Increased locking • Potential deadlocks – Affect page life expectancy – Impact memory distribution MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  17. 17. Case Study 1 • Metric is high, so what? • How do you tie into performance counter? – Sys.dm_db_index_usage_stats – Plan cache MAKING BUSINESS INTELLIGENT www.pragmaticworks.com Access Methods:Full Scans/sec
  18. 18. Case Study 2 • What’s wrong? • Why aren’t the other indexes used? • Are the right indexes in place? • What do you do? – Examine execution plans – Add in correct indexes MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  19. 19. November 6-9, Seattle, WA Scan Heavy Indexes • Demo MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  20. 20. Scan Heavy Indexes Summary • High scans on indexes can impact performance – Higher IO – More locking • More Blocking • Possible Deadlocking – Memory impacted • Find the occurrences – Identify indexes and analyze plans – Add alternative indexes MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  21. 21. Filtered Indexes
  22. 22. Filtered Indexes • Index with a WHERE clause – Only includes filtered rows – Decreases rows in index • Effect – Improved plan quality – Improved storage – Lower build time – Less maintenance • Benefit – Scan of small set of data MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  23. 23. Case Study • New data coming this week – Represents < 1% of rows • Can’t rebuild indexes – Statistics on new rows inaccurate • Need high quality plans – Indexes in place aren’t used • What do you do? MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  24. 24. Filtered Index Issue • Filter Criteria – Must be included – Can not be parameterized • Plan warning – Unmatched indexes MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  25. 25. November 6-9, Seattle, WA Filtered Indexes • Demo MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  26. 26. Filtered Index Summary • Consider filtered indexes for: – Large indexes with limited range of use – Tables with large number of new rows • Improves index performance – Smaller, lightweight, agile – Improved plan quality • Seeks over scans (small data over large data) • Scans over seeks (tiny data over small data) MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  27. 27. Missing Indexes
  28. 28. Missing Indexes • Optimize through materialization – Index versus statistics • Three options – Dynamic management views – Database Engine Tuning Advisor – Plan Cache MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  29. 29. Missing Indexes MAKING BUSINESS INTELLIGENT www.pragmaticworks.com MISSING INDEXES!!!
  30. 30. November 6-9, Seattle, WA Missing Indexes • Demo MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  31. 31. Missing Index Summary • These are FREE recommendations – Results of actual performance opportunities – Provide opportunity to focus on other needs • These are recommendations – Index schema to ensure value – Consolidate when possible – Review associated queries MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  32. 32. Foreign Key Indexes
  33. 33. Indexing Foreign Keys • Foreign keys enforcement – INSERT – UPDATE – DELETE • Performed in background • Unseen until a problem MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  34. 34. Indexing Foreign Key Issues • Unindexed foreign key – Constraint columns • Performance issues – Scan of column values – Increased locking – Blocking likely – Potential deadlocking MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  35. 35. Case Study Delete from SalesOrderHeader? MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  36. 36. Case Study Delete from SalesOrderDetail? MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  37. 37. Case Study Delete from SalesOrderHeaderSaleReason? MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  38. 38. November 6-9, Seattle, WA Indexing Foreign Keys • Demo MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  39. 39. Indexing Foreign Key Summary • Foreign keys are important – Enforce integrity of data – Constraints on values • Operations occur in background – DELETEs often source of issues – Can lead to deadlocks MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  40. 40. Learn More About Indexes MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  41. 41. Services Speed development through training, and rapid development services from Pragmatic Works. Products BI products to covert to a Microsoft BI platform and simplify development on the platform. Foundation Helping those who do not have the means to get into information technology achieve their dreams. For more information… Name: Jason Strate Email: jstrate@pragmaticworks.com Blog: www.jasonstrate.com Resource: jasonstrate.com/go/indexing

×