SlideShare uma empresa Scribd logo
1 de 41
Baixar para ler offline
5 Ways to Improve Performance
through Indexing
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
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
Indexes
Disappointment
5 Ways to Improve
Performance through
Indexing
Lookup Imbalance
Lookup Imbalance
• Excessive key lookups
– Exceed number of seeks
• Problems
– Increased CPU
– Increased IO
– Increased duration
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
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
Case Study 1
• What’s wrong?
• Do you see the pattern?
• What do you do?
– Move clustered index
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
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
Case Study 3
• What’s wrong?
• Do you see the pattern?
• What do you do?
– Add included columns
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
November 6-9, Seattle, WA
Lookup Imbalance
• Demo
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
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
Scan Heavy Indexes
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
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
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
November 6-9, Seattle, WA
Scan Heavy Indexes
• Demo
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
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
Filtered Indexes
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
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
Filtered Index Issue
• Filter Criteria
– Must be included
– Can not be parameterized
• Plan warning
– Unmatched indexes
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
November 6-9, Seattle, WA
Filtered Indexes
• Demo
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
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
Missing Indexes
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
Missing Indexes
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
MISSING
INDEXES!!!
November 6-9, Seattle, WA
Missing Indexes
• Demo
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
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
Foreign Key Indexes
Indexing Foreign Keys
• Foreign keys enforcement
– INSERT
– UPDATE
– DELETE
• Performed in background
• Unseen until a problem
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
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
Case Study
Delete from SalesOrderHeader?
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
Case Study
Delete from SalesOrderDetail?
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
Case Study
Delete from SalesOrderHeaderSaleReason?
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
November 6-9, Seattle, WA
Indexing Foreign Keys
• Demo
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
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
Learn More About Indexes
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
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

Mais conteúdo relacionado

Destaque (12)

An Integrated Framework on Mining Logs Files for Computing System Management
An Integrated Framework on Mining Logs Files for Computing System ManagementAn Integrated Framework on Mining Logs Files for Computing System Management
An Integrated Framework on Mining Logs Files for Computing System Management
 
Heaps
HeapsHeaps
Heaps
 
Files Management
Files ManagementFiles Management
Files Management
 
Merging files (Data Structure)
Merging files (Data Structure)Merging files (Data Structure)
Merging files (Data Structure)
 
Concept of computer files for Grade 12 learners
Concept of computer files for Grade 12 learnersConcept of computer files for Grade 12 learners
Concept of computer files for Grade 12 learners
 
Multi ways trees
Multi ways treesMulti ways trees
Multi ways trees
 
File organization
File organizationFile organization
File organization
 
File organisation
File organisationFile organisation
File organisation
 
File structures
File structuresFile structures
File structures
 
File Organization
File OrganizationFile Organization
File Organization
 
Lec 17 heap data structure
Lec 17 heap data structureLec 17 heap data structure
Lec 17 heap data structure
 
File organization
File organizationFile organization
File organization
 

Semelhante a 5 ways to improve performance through indexing

The final frontier
The final frontierThe final frontier
The final frontier
Terry Bunio
 
Relevancy and Search Quality Analysis - Search Technologies
Relevancy and Search Quality Analysis - Search TechnologiesRelevancy and Search Quality Analysis - Search Technologies
Relevancy and Search Quality Analysis - Search Technologies
enterprisesearchmeetup
 
Benchmarking Your Search Function l.ppt
Benchmarking Your Search Function l.pptBenchmarking Your Search Function l.ppt
Benchmarking Your Search Function l.ppt
Deepak Nagar
 

Semelhante a 5 ways to improve performance through indexing (20)

5 Amazing Reasons DBAs Need to Love Extended Events
5 Amazing Reasons DBAs Need to Love Extended Events5 Amazing Reasons DBAs Need to Love Extended Events
5 Amazing Reasons DBAs Need to Love Extended Events
 
Pr dc 2015 sql server is cheaper than open source
Pr dc 2015 sql server is cheaper than open sourcePr dc 2015 sql server is cheaper than open source
Pr dc 2015 sql server is cheaper than open source
 
The final frontier
The final frontierThe final frontier
The final frontier
 
Avoid Growing Pains: Scale Your App for the Enterprise (October 14, 2014)
Avoid Growing Pains: Scale Your App for the Enterprise (October 14, 2014)Avoid Growing Pains: Scale Your App for the Enterprise (October 14, 2014)
Avoid Growing Pains: Scale Your App for the Enterprise (October 14, 2014)
 
Optimising Queries - Series 1 Query Optimiser Architecture
Optimising Queries - Series 1 Query Optimiser ArchitectureOptimising Queries - Series 1 Query Optimiser Architecture
Optimising Queries - Series 1 Query Optimiser Architecture
 
Scalability and performance for e commerce
Scalability and performance for e commerceScalability and performance for e commerce
Scalability and performance for e commerce
 
SSAS Design &amp; Incremental Processing - PASSMN May 2010
SSAS Design &amp; Incremental Processing - PASSMN May 2010SSAS Design &amp; Incremental Processing - PASSMN May 2010
SSAS Design &amp; Incremental Processing - PASSMN May 2010
 
awari-ds-aula1.pdf
awari-ds-aula1.pdfawari-ds-aula1.pdf
awari-ds-aula1.pdf
 
Data Warehouse approaches with Dynamics AX
Data Warehouse  approaches with Dynamics AXData Warehouse  approaches with Dynamics AX
Data Warehouse approaches with Dynamics AX
 
Relevancy and Search Quality Analysis - Search Technologies
Relevancy and Search Quality Analysis - Search TechnologiesRelevancy and Search Quality Analysis - Search Technologies
Relevancy and Search Quality Analysis - Search Technologies
 
Choosing the Right Business Intelligence Tools for Your Data and Architectura...
Choosing the Right Business Intelligence Tools for Your Data and Architectura...Choosing the Right Business Intelligence Tools for Your Data and Architectura...
Choosing the Right Business Intelligence Tools for Your Data and Architectura...
 
Using Dashboards to Transform Application Data Visualization
Using Dashboards to Transform Application Data VisualizationUsing Dashboards to Transform Application Data Visualization
Using Dashboards to Transform Application Data Visualization
 
Using Dashboards to Transform Application Data Visualization
Using Dashboards to Transform Application Data VisualizationUsing Dashboards to Transform Application Data Visualization
Using Dashboards to Transform Application Data Visualization
 
Metadata discovery for enterprise packages - a better approach
Metadata discovery for enterprise packages - a better approachMetadata discovery for enterprise packages - a better approach
Metadata discovery for enterprise packages - a better approach
 
Large Data Volume Salesforce experiences
Large Data Volume Salesforce experiencesLarge Data Volume Salesforce experiences
Large Data Volume Salesforce experiences
 
ADV Slides: What the Aspiring or New Data Scientist Needs to Know About the E...
ADV Slides: What the Aspiring or New Data Scientist Needs to Know About the E...ADV Slides: What the Aspiring or New Data Scientist Needs to Know About the E...
ADV Slides: What the Aspiring or New Data Scientist Needs to Know About the E...
 
Geek Sync I Agile Data Management vs. Agile Data Modeling
Geek Sync I Agile Data Management vs. Agile Data ModelingGeek Sync I Agile Data Management vs. Agile Data Modeling
Geek Sync I Agile Data Management vs. Agile Data Modeling
 
Building Search and Personalization at Nordstrom Rack | Hautelook
Building Search and Personalization at Nordstrom Rack | HautelookBuilding Search and Personalization at Nordstrom Rack | Hautelook
Building Search and Personalization at Nordstrom Rack | Hautelook
 
Optimising Queries - Series 4 Designing Effective Indexes
Optimising Queries - Series 4 Designing Effective IndexesOptimising Queries - Series 4 Designing Effective Indexes
Optimising Queries - Series 4 Designing Effective Indexes
 
Benchmarking Your Search Function l.ppt
Benchmarking Your Search Function l.pptBenchmarking Your Search Function l.ppt
Benchmarking Your Search Function l.ppt
 

Mais de Jason Strate

BuildingSecurity Audits with Extended Events
BuildingSecurity Audits with Extended EventsBuildingSecurity Audits with Extended Events
BuildingSecurity Audits with Extended Events
Jason Strate
 
Discovering the plan cache (sql sat175)
Discovering the plan cache (sql sat175)Discovering the plan cache (sql sat175)
Discovering the plan cache (sql sat175)
Jason Strate
 
Introduction to SQL Server Security
Introduction to SQL Server SecurityIntroduction to SQL Server Security
Introduction to SQL Server Security
Jason Strate
 
What are you waiting for? (#SQLSat211)
What are you waiting for? (#SQLSat211)What are you waiting for? (#SQLSat211)
What are you waiting for? (#SQLSat211)
Jason Strate
 
Discovering the plan cache (#SQLSat211)
Discovering the plan cache (#SQLSat211)Discovering the plan cache (#SQLSat211)
Discovering the plan cache (#SQLSat211)
Jason Strate
 
Discovering the Plan Cache (#SQLSat 206)
Discovering the Plan Cache (#SQLSat 206)Discovering the Plan Cache (#SQLSat 206)
Discovering the Plan Cache (#SQLSat 206)
Jason Strate
 
A Function by Any Other Name is a Function
A Function by Any Other Name is a FunctionA Function by Any Other Name is a Function
A Function by Any Other Name is a Function
Jason Strate
 
What are you waiting for
What are you waiting forWhat are you waiting for
What are you waiting for
Jason Strate
 

Mais de Jason Strate (20)

Accelerating Business Intelligence Solutions with Microsoft Azure pass
Accelerating Business Intelligence Solutions with Microsoft Azure   passAccelerating Business Intelligence Solutions with Microsoft Azure   pass
Accelerating Business Intelligence Solutions with Microsoft Azure pass
 
The Plan Cache Whisperer - Performance Tuning SQL Server
The Plan Cache Whisperer - Performance Tuning SQL ServerThe Plan Cache Whisperer - Performance Tuning SQL Server
The Plan Cache Whisperer - Performance Tuning SQL Server
 
Strategies for SQL Server Index Analysis
Strategies for SQL Server Index AnalysisStrategies for SQL Server Index Analysis
Strategies for SQL Server Index Analysis
 
Leveraging Cloud for the Modern SQL Developer
Leveraging Cloud for the Modern SQL DeveloperLeveraging Cloud for the Modern SQL Developer
Leveraging Cloud for the Modern SQL Developer
 
Getting Started with Windows Azure and SQL Databases
Getting Started with Windows Azure and SQL DatabasesGetting Started with Windows Azure and SQL Databases
Getting Started with Windows Azure and SQL Databases
 
5 SQL Server Indexing Myths
5 SQL Server Indexing Myths5 SQL Server Indexing Myths
5 SQL Server Indexing Myths
 
Introduction to Columnstore Indexes
Introduction to Columnstore IndexesIntroduction to Columnstore Indexes
Introduction to Columnstore Indexes
 
The Flavors of Non-Clustered Indexes
The Flavors of Non-Clustered IndexesThe Flavors of Non-Clustered Indexes
The Flavors of Non-Clustered Indexes
 
Necessary Evils, Building Optimized CRUD Procedures
Necessary Evils, Building Optimized CRUD ProceduresNecessary Evils, Building Optimized CRUD Procedures
Necessary Evils, Building Optimized CRUD Procedures
 
How Do Non-Clustered Indexes Improve Performance?
How Do Non-Clustered Indexes Improve Performance?How Do Non-Clustered Indexes Improve Performance?
How Do Non-Clustered Indexes Improve Performance?
 
Choosing Your Clustered Index
Choosing Your Clustered IndexChoosing Your Clustered Index
Choosing Your Clustered Index
 
BuildingSecurity Audits with Extended Events
BuildingSecurity Audits with Extended EventsBuildingSecurity Audits with Extended Events
BuildingSecurity Audits with Extended Events
 
The Side Effect of NOLOCK
The Side Effect of NOLOCKThe Side Effect of NOLOCK
The Side Effect of NOLOCK
 
Discovering the plan cache (sql sat175)
Discovering the plan cache (sql sat175)Discovering the plan cache (sql sat175)
Discovering the plan cache (sql sat175)
 
Introduction to SQL Server Security
Introduction to SQL Server SecurityIntroduction to SQL Server Security
Introduction to SQL Server Security
 
What are you waiting for? (#SQLSat211)
What are you waiting for? (#SQLSat211)What are you waiting for? (#SQLSat211)
What are you waiting for? (#SQLSat211)
 
Discovering the plan cache (#SQLSat211)
Discovering the plan cache (#SQLSat211)Discovering the plan cache (#SQLSat211)
Discovering the plan cache (#SQLSat211)
 
Discovering the Plan Cache (#SQLSat 206)
Discovering the Plan Cache (#SQLSat 206)Discovering the Plan Cache (#SQLSat 206)
Discovering the Plan Cache (#SQLSat 206)
 
A Function by Any Other Name is a Function
A Function by Any Other Name is a FunctionA Function by Any Other Name is a Function
A Function by Any Other Name is a Function
 
What are you waiting for
What are you waiting forWhat are you waiting for
What are you waiting for
 

Último

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Último (20)

Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

5 ways to improve performance through indexing

  • 1. 5 Ways to Improve Performance through Indexing
  • 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. 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
  • 6. 5 Ways to Improve Performance through Indexing
  • 8. Lookup Imbalance • Excessive key lookups – Exceed number of seeks • Problems – Increased CPU – Increased IO – Increased duration MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  • 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. 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. 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. 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. November 6-9, Seattle, WA Lookup Imbalance • Demo MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  • 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
  • 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. 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. 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. November 6-9, Seattle, WA Scan Heavy Indexes • Demo MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  • 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
  • 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. 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. Filtered Index Issue • Filter Criteria – Must be included – Can not be parameterized • Plan warning – Unmatched indexes MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  • 25. November 6-9, Seattle, WA Filtered Indexes • Demo MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  • 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
  • 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. Missing Indexes MAKING BUSINESS INTELLIGENT www.pragmaticworks.com MISSING INDEXES!!!
  • 30. November 6-9, Seattle, WA Missing Indexes • Demo MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  • 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
  • 33. Indexing Foreign Keys • Foreign keys enforcement – INSERT – UPDATE – DELETE • Performed in background • Unseen until a problem MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  • 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. Case Study Delete from SalesOrderHeader? MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  • 36. Case Study Delete from SalesOrderDetail? MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  • 37. Case Study Delete from SalesOrderHeaderSaleReason? MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  • 38. November 6-9, Seattle, WA Indexing Foreign Keys • Demo MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  • 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. Learn More About Indexes MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  • 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