5 SQL Server Indexing Myths

  • 465 views
Uploaded on

There are many "best practices" around that help people decide how to index databases. Having these practices can help alleviate the time that it takes to design an indexing strategy for a database. …

There are many "best practices" around that help people decide how to index databases. Having these practices can help alleviate the time that it takes to design an indexing strategy for a database. These practices can be of great use, except when they are wrong. Join us in this session, as we discuss some common myths associated with indexes and then dive into the myths to demonstrate how they can be debunked. At the end of the session, you'll know a few more things about indexes and leave armed with scripts that can help you debunk these myths on your own.

http://pragmaticworks.com/LearningCenter/FreeTrainingWebinars/PastWebinars.aspx?ResourceId=654

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
465
On Slideshare
0
From Embeds
0
Number of Embeds
10

Actions

Shares
Downloads
18
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. INTELLIGENT DATA SOLUTIONS WWW.PRAGMATICWORKS.COM 5 SQL Server Indexing Myths
  • 2. INTELLIGENT DATA SOLUTIONS WWW.PRAGMATICWORKS.COM2 Introduction Jason Strate e: jstrate@pragmaticworks.com e: jasonstrate@gmail.com b: www.jasonstrate.com t: StrateSQL Resources www.jasonstrate.com/go/indexing
  • 3. INTELLIGENT DATA SOLUTIONS WWW.PRAGMATICWORKS.COM3 Unicorns aren’t real!
  • 4. INTELLIGENT DATA SOLUTIONS WWW.PRAGMATICWORKS.COM4 I want to believe!
  • 5. INTELLIGENT DATA SOLUTIONS WWW.PRAGMATICWORKS.COM5 But husky rhinos are!
  • 6. INTELLIGENT DATA SOLUTIONS WWW.PRAGMATICWORKS.COM6 Primary Keys Are Always Clustered
  • 7. INTELLIGENT DATA SOLUTIONS WWW.PRAGMATICWORKS.COM7 Primary Keys Are Always Clustered Primary keys are clustered by default Common point of confusion Often the desired behavior Is the primary key a good clustered index? Static and stable Ever increasing
  • 8. INTELLIGENT DATA SOLUTIONS WWW.PRAGMATICWORKS.COM Primary Keys Are Always Clustered Demo
  • 9. INTELLIGENT DATA SOLUTIONS WWW.PRAGMATICWORKS.COM9 Index Column Order Doesn’t Matter
  • 10. INTELLIGENT DATA SOLUTIONS WWW.PRAGMATICWORKS.COM10 Index Column Order Doesn’t Matter Using and seeking an index are not the same Read execution plans carefully Validate scans versus seeks Indexes are sorted left to right All columns are not required Scans aren’t necessarily bad
  • 11. INTELLIGENT DATA SOLUTIONS WWW.PRAGMATICWORKS.COM11 Index Column Order Doesn’t Matter Col1 Col2 A 1 A 2 A 3 B 1 B 2 B 3 C 1 C 2 C 3 A 1
  • 12. INTELLIGENT DATA SOLUTIONS WWW.PRAGMATICWORKS.COM Index Column Order Doesn’t Matter Demo
  • 13. INTELLIGENT DATA SOLUTIONS WWW.PRAGMATICWORKS.COM13 Clustered Indexes Are Physically Ordered
  • 14. INTELLIGENT DATA SOLUTIONS WWW.PRAGMATICWORKS.COM14 Clustered Indexes Are Physically Ordered Clustered indexes sort data within the index Accurately find specific values A before B, B before C Physical sorted at the tree level Path data access directly to the required page Logically sorted at the page level Minimize page rewrites on DML
  • 15. INTELLIGENT DATA SOLUTIONS WWW.PRAGMATICWORKS.COM Clustered Indexes Are Physically Ordered Demo
  • 16. INTELLIGENT DATA SOLUTIONS WWW.PRAGMATICWORKS.COM16 Fill Factor Affects Insert Operations
  • 17. INTELLIGENT DATA SOLUTIONS WWW.PRAGMATICWORKS.COM17 Fill Factor Affects Insert Operations Fill factor leaves space on data pages Why do we do this? Leave space for DML operations Mitigate page splits during DML operations Provides a buffer for data variability
  • 18. INTELLIGENT DATA SOLUTIONS WWW.PRAGMATICWORKS.COM18 Fill Factor Affects Insert Operations
  • 19. INTELLIGENT DATA SOLUTIONS WWW.PRAGMATICWORKS.COM19 Fill Factor Affects Insert Operations
  • 20. INTELLIGENT DATA SOLUTIONS WWW.PRAGMATICWORKS.COM Fill Factor Affects Insert Operations Demo
  • 21. INTELLIGENT DATA SOLUTIONS WWW.PRAGMATICWORKS.COM21 Every Table Should Have a Heap/Clustered Index
  • 22. INTELLIGENT DATA SOLUTIONS WWW.PRAGMATICWORKS.COM22 Every Table Should Have a XXX Index Blanket statements suck Doesn’t account for all situations Or even most situations Not 50/50 Not 90/10 Is there a safe answer?
  • 23. INTELLIGENT DATA SOLUTIONS WWW.PRAGMATICWORKS.COM23 Heap / Clustered Indexes Heap • Non-selective access • Bulk Loaded tables • Fragmentation prone with high inserts • Staging tables Clustered Index • Highly modified data • Singleton access • Range scans • Key ordered results
  • 24. INTELLIGENT DATA SOLUTIONS WWW.PRAGMATICWORKS.COM 5 SQL Server Indexing Myths Questions?
  • 25. Products Improve the quality, productivity, and performance of your SQL Server and BI solutions. Services Speed development through training and rapid development services from Pragmatic Works. Foundation Helping those who don’t have the means to get into information technology and to achieve their dreams. Name: Jason Strate Email: jstrate@pragmaticworks.com Blog: www.jasonstrate.com Resource: www.jasonstrate.com/go/indexing Need Help? jasonstrate.com/go/vmdba