SlideShare une entreprise Scribd logo
1  sur  41
Télécharger pour lire hors ligne
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

Contenu connexe

En vedette (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
 

Similaire à 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
 

Similaire à 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
 

Plus 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
 

Plus 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
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

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