SlideShare a Scribd company logo
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or
other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must
respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided
after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION
Presented by Harsh Chawla
SQL Community Session –
Delhi NCR
DBA: Query Tuning and Optimization - Expert
1. DB Consultant Approaches
2. Fetching Execution Plans
3. Common execution plan patterns
4. Understand the data distribution
5. Q&A
Welcome.
Microsoft Services
helps businesses
around the world
maximize their return
on investment in
Microsoft products
and technologies.
12/28/2015 2
Proactive
Approach
12/28/2015 3
• Leverage MDW
• Have a Performance Baseline
Understand the load
• Missing Indexes
• Duplicate Indexes
• Unused Indexes
Understand the Indexing
• Leverage Plan hash and Query Hash to find
top resource intensive queries
• Leverage MDW to identify the top queries
Fetch Top Queries for Tuning
Reactive
Approach
12/28/2015 4
• Leverage MDW /SQLNexus to identify the resource
contention
Identify the Top Bottlenecks
• Leverage Plan hash and Query Hash to find top
resource intensive queries
• Leverage MDW to identify the top queries
Identify the Top Resource intensive queries
• Set Statistics IO ON
• Set Statistics Time on
• Set Statistics Profile on
Explore the execution plans
Fetching
Execution
plans
12/28/2015 5
• Estimated Vs Actual
• DMVs show only estimated plans
• Extract the variables from the
execution plan
• Execute the query to get the actual
execution plan
Common
Execution Plan
Patterns
12/28/2015 6
• Index Seek
• Index Scan
• Key/RID Lookups
• Implicit Conversions
• Missing Statistics Warning
• Sort Warning
• Hash Warning
Let’s Delve
Deeper
12/28/2015 7
• Cardinality Estimation
• Residual Predicates
• Impact of Data distribution
• Sorts
Cardinality
Estimation
12/28/2015 8
• Beauty lies in the data
• There is never a coincidence
• Wrong Estimation cause Hash
warnings/sort warning or almost
every mess up
• It’s the biggest gotcha while
query tuning
• Try to investigate the numbers
Demo
12/28/2015 9
Residual
Predicates
12/28/2015 10
• What’s a Predicate
• If the predicate is not
SARGable, Residual Predicates
will be seen
Demo
12/28/2015 11
Impact of data distribution
Demo
12/28/2015 12
Sort
Q&A
12/28/2015 13

More Related Content

Similar to Query tuning optimization

Building a Data Strategy Your C-Suite Will Support
Building a Data Strategy Your C-Suite Will SupportBuilding a Data Strategy Your C-Suite Will Support
Building a Data Strategy Your C-Suite Will Support
Reid Colson
 
ANIn Coimbatore Sep 2023 | Agile for data science by Venkatesa Prasanna Selvaraj
ANIn Coimbatore Sep 2023 | Agile for data science by Venkatesa Prasanna SelvarajANIn Coimbatore Sep 2023 | Agile for data science by Venkatesa Prasanna Selvaraj
ANIn Coimbatore Sep 2023 | Agile for data science by Venkatesa Prasanna Selvaraj
AgileNetwork
 
Strategy and roadmap slides
Strategy and roadmap slidesStrategy and roadmap slides
Strategy and roadmap slides
Data Blueprint
 
Data-Ed Online Webinar: Data-centric Strategy & Roadmap
Data-Ed Online Webinar: Data-centric Strategy & RoadmapData-Ed Online Webinar: Data-centric Strategy & Roadmap
Data-Ed Online Webinar: Data-centric Strategy & Roadmap
DATAVERSITY
 
Trends in Enterprise Advanced Analytics
Trends in Enterprise Advanced AnalyticsTrends in Enterprise Advanced Analytics
Trends in Enterprise Advanced Analytics
DATAVERSITY
 
Most Common Data Governance Challenges in the Digital Economy
Most Common Data Governance Challenges in the Digital EconomyMost Common Data Governance Challenges in the Digital Economy
Most Common Data Governance Challenges in the Digital Economy
Robyn Bollhorst
 
Alphonso_Triplett.Sr_Prometheus_Phoenix
Alphonso_Triplett.Sr_Prometheus_PhoenixAlphonso_Triplett.Sr_Prometheus_Phoenix
Alphonso_Triplett.Sr_Prometheus_Phoenix
Alphonso K Triplett SR.
 
Building Data Warehouse in SQL Server
Building Data Warehouse in SQL ServerBuilding Data Warehouse in SQL Server
Building Data Warehouse in SQL Server
Antonios Chatzipavlis
 
Driving A New Age Of Connected Planning
Driving A New Age Of Connected PlanningDriving A New Age Of Connected Planning
Driving A New Age Of Connected Planning
SCL HUB
 
How to Structure the Data Organization
How to Structure the Data OrganizationHow to Structure the Data Organization
How to Structure the Data Organization
Robyn Bollhorst
 
Data architecture around risk management
Data architecture around risk managementData architecture around risk management
Data architecture around risk management
Suvradeep Rudra
 
Kythera BioPharma Commercial Infrastructure 2015 05 28 final
Kythera BioPharma Commercial Infrastructure 2015 05 28 finalKythera BioPharma Commercial Infrastructure 2015 05 28 final
Kythera BioPharma Commercial Infrastructure 2015 05 28 final
Michael W. Hughes
 
March 2016 PHXTUG Meeting
March 2016 PHXTUG MeetingMarch 2016 PHXTUG Meeting
March 2016 PHXTUG Meeting
Michael Perillo
 
Future Proof Your DAM
Future Proof Your DAMFuture Proof Your DAM
Future Proof Your DAM
jflorance
 
Synergis60: 6 Critical Steps to Implementing Data Managment
Synergis60: 6 Critical Steps to Implementing Data ManagmentSynergis60: 6 Critical Steps to Implementing Data Managment
Synergis60: 6 Critical Steps to Implementing Data Managment
Synergis Engineering Design Solutions
 
Datascience methodology
Datascience methodologyDatascience methodology
Datascience methodology
ArunakumariAkula1
 
Innovative Data Strategies for Advanced Analytics Solutions and the Role of D...
Innovative Data Strategies for Advanced Analytics Solutions and the Role of D...Innovative Data Strategies for Advanced Analytics Solutions and the Role of D...
Innovative Data Strategies for Advanced Analytics Solutions and the Role of D...
Denodo
 
Edr mds a less is more approach to MDM
Edr mds a less is more approach to MDMEdr mds a less is more approach to MDM
Edr mds a less is more approach to MDM
Thor Henning Hetland
 
2013 ALPFA Leadership Submit, Data Analytics in Practice
2013 ALPFA Leadership Submit, Data Analytics in Practice2013 ALPFA Leadership Submit, Data Analytics in Practice
2013 ALPFA Leadership Submit, Data Analytics in Practice
Alejandro Jaramillo
 
Data-Ed: Metadata Strategies
 Data-Ed: Metadata Strategies Data-Ed: Metadata Strategies
Data-Ed: Metadata Strategies
Data Blueprint
 

Similar to Query tuning optimization (20)

Building a Data Strategy Your C-Suite Will Support
Building a Data Strategy Your C-Suite Will SupportBuilding a Data Strategy Your C-Suite Will Support
Building a Data Strategy Your C-Suite Will Support
 
ANIn Coimbatore Sep 2023 | Agile for data science by Venkatesa Prasanna Selvaraj
ANIn Coimbatore Sep 2023 | Agile for data science by Venkatesa Prasanna SelvarajANIn Coimbatore Sep 2023 | Agile for data science by Venkatesa Prasanna Selvaraj
ANIn Coimbatore Sep 2023 | Agile for data science by Venkatesa Prasanna Selvaraj
 
Strategy and roadmap slides
Strategy and roadmap slidesStrategy and roadmap slides
Strategy and roadmap slides
 
Data-Ed Online Webinar: Data-centric Strategy & Roadmap
Data-Ed Online Webinar: Data-centric Strategy & RoadmapData-Ed Online Webinar: Data-centric Strategy & Roadmap
Data-Ed Online Webinar: Data-centric Strategy & Roadmap
 
Trends in Enterprise Advanced Analytics
Trends in Enterprise Advanced AnalyticsTrends in Enterprise Advanced Analytics
Trends in Enterprise Advanced Analytics
 
Most Common Data Governance Challenges in the Digital Economy
Most Common Data Governance Challenges in the Digital EconomyMost Common Data Governance Challenges in the Digital Economy
Most Common Data Governance Challenges in the Digital Economy
 
Alphonso_Triplett.Sr_Prometheus_Phoenix
Alphonso_Triplett.Sr_Prometheus_PhoenixAlphonso_Triplett.Sr_Prometheus_Phoenix
Alphonso_Triplett.Sr_Prometheus_Phoenix
 
Building Data Warehouse in SQL Server
Building Data Warehouse in SQL ServerBuilding Data Warehouse in SQL Server
Building Data Warehouse in SQL Server
 
Driving A New Age Of Connected Planning
Driving A New Age Of Connected PlanningDriving A New Age Of Connected Planning
Driving A New Age Of Connected Planning
 
How to Structure the Data Organization
How to Structure the Data OrganizationHow to Structure the Data Organization
How to Structure the Data Organization
 
Data architecture around risk management
Data architecture around risk managementData architecture around risk management
Data architecture around risk management
 
Kythera BioPharma Commercial Infrastructure 2015 05 28 final
Kythera BioPharma Commercial Infrastructure 2015 05 28 finalKythera BioPharma Commercial Infrastructure 2015 05 28 final
Kythera BioPharma Commercial Infrastructure 2015 05 28 final
 
March 2016 PHXTUG Meeting
March 2016 PHXTUG MeetingMarch 2016 PHXTUG Meeting
March 2016 PHXTUG Meeting
 
Future Proof Your DAM
Future Proof Your DAMFuture Proof Your DAM
Future Proof Your DAM
 
Synergis60: 6 Critical Steps to Implementing Data Managment
Synergis60: 6 Critical Steps to Implementing Data ManagmentSynergis60: 6 Critical Steps to Implementing Data Managment
Synergis60: 6 Critical Steps to Implementing Data Managment
 
Datascience methodology
Datascience methodologyDatascience methodology
Datascience methodology
 
Innovative Data Strategies for Advanced Analytics Solutions and the Role of D...
Innovative Data Strategies for Advanced Analytics Solutions and the Role of D...Innovative Data Strategies for Advanced Analytics Solutions and the Role of D...
Innovative Data Strategies for Advanced Analytics Solutions and the Role of D...
 
Edr mds a less is more approach to MDM
Edr mds a less is more approach to MDMEdr mds a less is more approach to MDM
Edr mds a less is more approach to MDM
 
2013 ALPFA Leadership Submit, Data Analytics in Practice
2013 ALPFA Leadership Submit, Data Analytics in Practice2013 ALPFA Leadership Submit, Data Analytics in Practice
2013 ALPFA Leadership Submit, Data Analytics in Practice
 
Data-Ed: Metadata Strategies
 Data-Ed: Metadata Strategies Data-Ed: Metadata Strategies
Data-Ed: Metadata Strategies
 

More from Harsh Chawla

Alwayson AG enhancements
Alwayson AG enhancementsAlwayson AG enhancements
Alwayson AG enhancements
Harsh Chawla
 
Windows clustering and quorum basics
Windows clustering and quorum basicsWindows clustering and quorum basics
Windows clustering and quorum basics
Harsh Chawla
 
AlwaysON Basics
AlwaysON BasicsAlwaysON Basics
AlwaysON Basics
Harsh Chawla
 
AlwaysON FCI
AlwaysON FCIAlwaysON FCI
AlwaysON FCI
Harsh Chawla
 
Storage spaces - for SQL Server Workloads
Storage spaces - for SQL Server WorkloadsStorage spaces - for SQL Server Workloads
Storage spaces - for SQL Server Workloads
Harsh Chawla
 
Pssdiag and sql nexus
Pssdiag and sql nexusPssdiag and sql nexus
Pssdiag and sql nexus
Harsh Chawla
 
Manage sql server proactively
Manage sql server proactivelyManage sql server proactively
Manage sql server proactively
Harsh Chawla
 
SQL Azure DB - BCDR
SQL Azure DB - BCDRSQL Azure DB - BCDR
SQL Azure DB - BCDR
Harsh Chawla
 

More from Harsh Chawla (8)

Alwayson AG enhancements
Alwayson AG enhancementsAlwayson AG enhancements
Alwayson AG enhancements
 
Windows clustering and quorum basics
Windows clustering and quorum basicsWindows clustering and quorum basics
Windows clustering and quorum basics
 
AlwaysON Basics
AlwaysON BasicsAlwaysON Basics
AlwaysON Basics
 
AlwaysON FCI
AlwaysON FCIAlwaysON FCI
AlwaysON FCI
 
Storage spaces - for SQL Server Workloads
Storage spaces - for SQL Server WorkloadsStorage spaces - for SQL Server Workloads
Storage spaces - for SQL Server Workloads
 
Pssdiag and sql nexus
Pssdiag and sql nexusPssdiag and sql nexus
Pssdiag and sql nexus
 
Manage sql server proactively
Manage sql server proactivelyManage sql server proactively
Manage sql server proactively
 
SQL Azure DB - BCDR
SQL Azure DB - BCDRSQL Azure DB - BCDR
SQL Azure DB - BCDR
 

Recently uploaded

zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
Alex Pruden
 
dbms calicut university B. sc Cs 4th sem.pdf
dbms  calicut university B. sc Cs 4th sem.pdfdbms  calicut university B. sc Cs 4th sem.pdf
dbms calicut university B. sc Cs 4th sem.pdf
Shinana2
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Wask
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Tatiana Kojar
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Jeffrey Haguewood
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Precisely
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
Edge AI and Vision Alliance
 

Recently uploaded (20)

zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
 
dbms calicut university B. sc Cs 4th sem.pdf
dbms  calicut university B. sc Cs 4th sem.pdfdbms  calicut university B. sc Cs 4th sem.pdf
dbms calicut university B. sc Cs 4th sem.pdf
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
 

Query tuning optimization

  • 1. © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION Presented by Harsh Chawla SQL Community Session – Delhi NCR DBA: Query Tuning and Optimization - Expert
  • 2. 1. DB Consultant Approaches 2. Fetching Execution Plans 3. Common execution plan patterns 4. Understand the data distribution 5. Q&A Welcome. Microsoft Services helps businesses around the world maximize their return on investment in Microsoft products and technologies. 12/28/2015 2
  • 3. Proactive Approach 12/28/2015 3 • Leverage MDW • Have a Performance Baseline Understand the load • Missing Indexes • Duplicate Indexes • Unused Indexes Understand the Indexing • Leverage Plan hash and Query Hash to find top resource intensive queries • Leverage MDW to identify the top queries Fetch Top Queries for Tuning
  • 4. Reactive Approach 12/28/2015 4 • Leverage MDW /SQLNexus to identify the resource contention Identify the Top Bottlenecks • Leverage Plan hash and Query Hash to find top resource intensive queries • Leverage MDW to identify the top queries Identify the Top Resource intensive queries • Set Statistics IO ON • Set Statistics Time on • Set Statistics Profile on Explore the execution plans
  • 5. Fetching Execution plans 12/28/2015 5 • Estimated Vs Actual • DMVs show only estimated plans • Extract the variables from the execution plan • Execute the query to get the actual execution plan
  • 6. Common Execution Plan Patterns 12/28/2015 6 • Index Seek • Index Scan • Key/RID Lookups • Implicit Conversions • Missing Statistics Warning • Sort Warning • Hash Warning
  • 7. Let’s Delve Deeper 12/28/2015 7 • Cardinality Estimation • Residual Predicates • Impact of Data distribution • Sorts
  • 8. Cardinality Estimation 12/28/2015 8 • Beauty lies in the data • There is never a coincidence • Wrong Estimation cause Hash warnings/sort warning or almost every mess up • It’s the biggest gotcha while query tuning • Try to investigate the numbers
  • 10. Residual Predicates 12/28/2015 10 • What’s a Predicate • If the predicate is not SARGable, Residual Predicates will be seen
  • 11. Demo 12/28/2015 11 Impact of data distribution

Editor's Notes

  1. Add all the scripts to identify top queries
  2. Show Demo on basic SQL Execution Estimated Vs Actual Show the Parametrized query and explain how they can get the parameters out of the execution plan Get the query hash and plan hash  Only zero cost plans are not shown here Get the execution plan from the sys.dm_exec_query_plans and sys.dm_exec_query_stats
  3. Hash warning sort warning - everything happens due to wrong cardinality estimation
  4. Show Demo for Basic Query Execution.sql Improving cardinality estimation Also tell everything is dependant on statistics 4. What if we don’t have statistics , how many rows will be estimated 5. Always keep your statistics updated 6. Auto create stats and auto update stats enable
  5. Demo