SlideShare uma empresa Scribd logo
1 de 35
Query tuning techniques
Rajnikant Tandel, DBA Manager, Datavail
Anup Gopinathan, Sr. SQL Server DBA, Datavail
Optimize SQL Server
Please silence
cell phones
Free online webinar
events
Free 1-day local
training events
Local user groups
around the world
Online special
interest user groups
Business analytics
training
Get involved
Explore
everything
PASS has
to offer
Free Online Resources
Newsletters
PASS.org
Download the GuideBook App
and search: PASS Summit 2018
Follow the QR code link displayed on session
signage throughout the conference venue and
in the program guide
Session
evaluations
Your feedback is
important and valuable.
Go to passSummit.com
3 Ways to Access:
Submit by 5pm Friday, November 16th to win prizes.
Anup Gopinathan
Sr. SQL Server DBA, Datavail
Sr. DBA with over 11 years of
experience in database design,
development & administration and
cloud computing. Extensive customer
engagement experience, supported
and worked with various customers.
Database performance tuning
Query tuning, execution plan analysis, index
and statistics optimization.
Database Scalability
Table partitioning, analyze isolation and
locking mechanisms, load balancing
/anupgopinathannair
@GopinathanAnup
Powershell scripting and
automations
Cloud Data Architecture/Cloud
Migration
Design highly available and scalable database
systems in cloud, migrate database from On-
premises to cloud
Rajnikant Tandel
DBA Manager
I’m a Microsoft Certified Solution
Associate, SQL Server 2012/2014 and
have over 15 years of SQL Server DBA
experience on relational databases
and application development and
specialize in performance tuning,
scalability and maintainability of large
scale SQL Servers. I’ve worked
extensively on performance tuning
and query optimization projects.
/rajnikant-tandel
@tandelrajni
Background
• Programmer
• Database Developer/DBA
• Database Administrator
• DBA Manager
Datavail Overview
Databases, Analytics, and
Application Data Integration
13+ years delivering
data services
300+ customers with
average client
retention of 7 years
Managed services,
projects, and staffing
• All major platforms: SQL, Oracle,
DB2, MySQL, Mongo DB
• Comprehensive development &
operational services
• US & Global models
• Reactive and proactive services
Database
Operations
• Microsoft SSRS, SSIS, SSAS
• PowerBI
• Oracle OBIEE, BICS, Golden
Gate
• EBS
• Hyperion/Essbase
• Microsoft Dynamics
• SharePoint
• Custom development
• Microsoft .NET
• Oracle APEX
Analytics, Visualization & Integration
Application
Management
We are data specialists
• Informatica
• Oracle Data Integrator
• ETL development and
operational run
Win Shoes
Fill out the session survey
for a chance to win an
exclusive pair of Datavail’s
running shoes!
• T-SQL new functions and performance – How to use SQL Server 2017 new
string functions to improve performance?
• Lock Escalation – How? When? Why?
• Table Variable V/S Temporary table V/S Correlated Subquery – compare
performance.
• Parameter sniffing – a look into how performance is affected.
Agenda
T-SQL new functions and performance
Example:
select category_code,
STRING_AGG(category_desc, ', ') within group
(order by category_desc) categories
from category
group by category_code
category_code categories
1 Groceries, Lodging, Meals, Travel
2
Clothing, Communication, Electronics,
Entertainment, Home Supplies, Misc
STRING_AGG()
Concatenates the values of
string expressions and places
separator values between
them. The separator is not
added at the end of string.
STRING_AGG()
T-SQL new functions and performance
TRANSLATE()
Returns the string provided as a
first argument after some
characters specified in the
second argument are translated
into a destination set of
characters.
TRANSLATE (inputstring,
characters,
translations)
Example:
SELECT TRANSLATE('2*[3+4]/{7-2}',
'[]{}', '()()’);
Output:
2*(3+4)/(7-2)
TRANSLATE()
T-SQL new functions and performance
Summary
• STRING_AGG() or TRANSLATE() perform better than user defined function or
other T-SQL methods
• Use CAST() when get an error “STRING_AGG aggregation result exceeded the
limit of 8000 bytes.”
• Consider replacing user defined function with new T-SQL functions
Questions &
Answers
Lock Escalation
The process of acquiring
higher level lock instead of
many smaller locks is called
lock escalation.
How does escalation happen?
1250
5000
Row locks Page Lock Table lock
Can we disable the lock escalation?
Table hints
• Row lock
• Page lock
ALTER TABLE CHARGE SET (LOCK_ESCALATION
= TABLE | DISABLE | AUTO)
• TABLE
• DISABLE
• AUTO
There are some options available to control it.
Lock Escalation
Summary
• Lock escalation can be controlled by
using table hints and by disabling
escalation at table level.
• Understand the pros and cons of
each method.
• SQL Engine can still escalate
• “TEST”
Questions &
Answers
Table Variable vs
Temp Table vs Correlated Subquery
Table Variable
• Can only be accessed within the batch and scope in which
they are declared
• Stored in TempDB
• Because of the well-defined scope, a table variable
generally uses fewer resources than a temporary table.
• No statistics-based recompiles
• Dropped automatically
DECLARE @Totalcharge AS TABLE
(Charge_no INT,
Amount money,
Date_Inserted datetime)
There’s
comfort in
knowing that
everything is
temporary.
Table Variable vs
Temp Table vs Correlated Subquery
Temporary Table
• Stored in TempDB
• Can create Indexes
• Deleting a Temporary Table
• Automatically when connection is
closed
• Manually using DROP Table
statement
• Performs better with large
number of rows
create table #Totalcharge
(Charge_no INT,
Amount money,
Date_Inserted datetime)
Table Variable vs
Temp Table vs Correlated Subquery
Correlated Subquery
• A correlated subquery is a
SELECT statement nested
inside another T-SQL
statement, which contains
a reference to one or more
columns in the outer
query.
• The correlated subquery
will be run once for each
candidate row selected by
the outer query.
SELECT column1, column2, ....
FROM table1 outer
WHERE column1 operator
(SELECT column1, column2
FROM table2
WHERE expr1 = outer.expr2);
Table Variable vs
Temp Table vs
Correlated Subquery
Table Variable vs Temp Table vs Correlated
Subquery
Summary
• Table variable performs well for
smaller set of rows
• Low maintenance cost
• No statistics-based recompiles
• Temp Table performs better for larger result set
• Can Create Indexes and Statistics
• Correlated subquery can be inefficient because it evaluated once for each row processed
by the outer query
Questions &
Answers
Parameter Sniffing
The execution plan for
stored procedures does
not work well for some
arguments.
Is this a bug?
Parameter sniffing
is not a bug
Parameter
Sniffing
Summary
• Recompile
• OPTION (OPTIMIZE FOR (@VARIABLE=VALUE | UNKNOWN))
• Disable parameter sniffing using Trace Flag 4136 / Database Scoped
Configuration
• local variableIt is not a bug.
• Analyze your workloads
• Testing
Questions &
Answers
References
• www.mssqltips.com
• sqlmag.com
• sqlservercentral
• stackoverflow.com
• Sqlserverperformance
• Statisticsparser.com
Thank You
Rajnikant Tandel
@tandelrajni
Rajnikant.Tandel@datavail.com
Anup Gopinathan
@GopinathanAnup
Anup.Gopinathan@datavail.com
Learn more from Learn more from
Win Shoes
Fill out the session survey
for a chance to win an
exclusive pair of Datavail’s
running shoes!

Mais conteúdo relacionado

Mais procurados

Brad McGehee Intepreting Execution Plans Mar09
Brad McGehee Intepreting Execution Plans Mar09Brad McGehee Intepreting Execution Plans Mar09
Brad McGehee Intepreting Execution Plans Mar09guest9d79e073
 
Before you optimize: Understanding Execution Plans
Before you optimize: Understanding Execution PlansBefore you optimize: Understanding Execution Plans
Before you optimize: Understanding Execution PlansTimothy Corey
 
Uncovering SQL Server query problems with execution plans - Tony Davis
Uncovering SQL Server query problems with execution plans - Tony DavisUncovering SQL Server query problems with execution plans - Tony Davis
Uncovering SQL Server query problems with execution plans - Tony DavisRed Gate Software
 
IBM SPSS Statistics Subscription (월 구독) 제품 구성
IBM SPSS Statistics Subscription (월 구독) 제품 구성 IBM SPSS Statistics Subscription (월 구독) 제품 구성
IBM SPSS Statistics Subscription (월 구독) 제품 구성 Jin Sol Kim 김진솔
 
Exciting Features for SQL Devs in SQL 2012
Exciting Features for SQL Devs in SQL 2012Exciting Features for SQL Devs in SQL 2012
Exciting Features for SQL Devs in SQL 2012Brij Mishra
 
Back to the future - Temporal Table in SQL Server 2016
Back to the future - Temporal Table in SQL Server 2016Back to the future - Temporal Table in SQL Server 2016
Back to the future - Temporal Table in SQL Server 2016Stéphane Fréchette
 
MS SQL SERVER: Programming sql server data mining
MS SQL SERVER: Programming sql server data miningMS SQL SERVER: Programming sql server data mining
MS SQL SERVER: Programming sql server data miningDataminingTools Inc
 
Efficient SPARQL to SQL translation with user defined mapping
Efficient SPARQL to SQL translation with user defined mappingEfficient SPARQL to SQL translation with user defined mapping
Efficient SPARQL to SQL translation with user defined mappingMiloš Chaloupka
 
Pass 2018 introduction to dax
Pass 2018 introduction to daxPass 2018 introduction to dax
Pass 2018 introduction to daxIke Ellis
 
Taming the Data Science Monster with A New ‘Sword’ – U-SQL
Taming the Data Science Monster with A New ‘Sword’ – U-SQLTaming the Data Science Monster with A New ‘Sword’ – U-SQL
Taming the Data Science Monster with A New ‘Sword’ – U-SQLMichael Rys
 
Window functions with SQL Server 2016
Window functions with SQL Server 2016Window functions with SQL Server 2016
Window functions with SQL Server 2016Mark Tabladillo
 
Project A Data Modelling Best Practices Part II: How to Build a Data Warehouse?
Project A Data Modelling Best Practices Part II: How to Build a Data Warehouse?Project A Data Modelling Best Practices Part II: How to Build a Data Warehouse?
Project A Data Modelling Best Practices Part II: How to Build a Data Warehouse?Martin Loetzsch
 
Hundreds of queries in the time of one - Gianmario Spacagna
Hundreds of queries in the time of one - Gianmario SpacagnaHundreds of queries in the time of one - Gianmario Spacagna
Hundreds of queries in the time of one - Gianmario SpacagnaSpark Summit
 
02 database oprimization - improving sql performance - ent-db
02  database oprimization - improving sql performance - ent-db02  database oprimization - improving sql performance - ent-db
02 database oprimization - improving sql performance - ent-dbuncleRhyme
 
Amazon Redshift For Data Analysts
Amazon Redshift For Data AnalystsAmazon Redshift For Data Analysts
Amazon Redshift For Data AnalystsCan Abacıgil
 

Mais procurados (20)

Sql performance tuning
Sql performance tuningSql performance tuning
Sql performance tuning
 
Brad McGehee Intepreting Execution Plans Mar09
Brad McGehee Intepreting Execution Plans Mar09Brad McGehee Intepreting Execution Plans Mar09
Brad McGehee Intepreting Execution Plans Mar09
 
Tunning overview
Tunning overviewTunning overview
Tunning overview
 
SQL Windowing
SQL WindowingSQL Windowing
SQL Windowing
 
Before you optimize: Understanding Execution Plans
Before you optimize: Understanding Execution PlansBefore you optimize: Understanding Execution Plans
Before you optimize: Understanding Execution Plans
 
Uncovering SQL Server query problems with execution plans - Tony Davis
Uncovering SQL Server query problems with execution plans - Tony DavisUncovering SQL Server query problems with execution plans - Tony Davis
Uncovering SQL Server query problems with execution plans - Tony Davis
 
IBM SPSS Statistics Subscription (월 구독) 제품 구성
IBM SPSS Statistics Subscription (월 구독) 제품 구성 IBM SPSS Statistics Subscription (월 구독) 제품 구성
IBM SPSS Statistics Subscription (월 구독) 제품 구성
 
Exciting Features for SQL Devs in SQL 2012
Exciting Features for SQL Devs in SQL 2012Exciting Features for SQL Devs in SQL 2012
Exciting Features for SQL Devs in SQL 2012
 
Back to the future - Temporal Table in SQL Server 2016
Back to the future - Temporal Table in SQL Server 2016Back to the future - Temporal Table in SQL Server 2016
Back to the future - Temporal Table in SQL Server 2016
 
MS SQL SERVER: Programming sql server data mining
MS SQL SERVER: Programming sql server data miningMS SQL SERVER: Programming sql server data mining
MS SQL SERVER: Programming sql server data mining
 
Efficient SPARQL to SQL translation with user defined mapping
Efficient SPARQL to SQL translation with user defined mappingEfficient SPARQL to SQL translation with user defined mapping
Efficient SPARQL to SQL translation with user defined mapping
 
Pass 2018 introduction to dax
Pass 2018 introduction to daxPass 2018 introduction to dax
Pass 2018 introduction to dax
 
Taming the Data Science Monster with A New ‘Sword’ – U-SQL
Taming the Data Science Monster with A New ‘Sword’ – U-SQLTaming the Data Science Monster with A New ‘Sword’ – U-SQL
Taming the Data Science Monster with A New ‘Sword’ – U-SQL
 
Window functions with SQL Server 2016
Window functions with SQL Server 2016Window functions with SQL Server 2016
Window functions with SQL Server 2016
 
SAS Online Training
SAS Online TrainingSAS Online Training
SAS Online Training
 
SAS Online Training
SAS Online TrainingSAS Online Training
SAS Online Training
 
Project A Data Modelling Best Practices Part II: How to Build a Data Warehouse?
Project A Data Modelling Best Practices Part II: How to Build a Data Warehouse?Project A Data Modelling Best Practices Part II: How to Build a Data Warehouse?
Project A Data Modelling Best Practices Part II: How to Build a Data Warehouse?
 
Hundreds of queries in the time of one - Gianmario Spacagna
Hundreds of queries in the time of one - Gianmario SpacagnaHundreds of queries in the time of one - Gianmario Spacagna
Hundreds of queries in the time of one - Gianmario Spacagna
 
02 database oprimization - improving sql performance - ent-db
02  database oprimization - improving sql performance - ent-db02  database oprimization - improving sql performance - ent-db
02 database oprimization - improving sql performance - ent-db
 
Amazon Redshift For Data Analysts
Amazon Redshift For Data AnalystsAmazon Redshift For Data Analysts
Amazon Redshift For Data Analysts
 

Semelhante a SQL Pass Summit Presentations from Datavail - Optimize SQL Server: Query Tuning Techniques

Tuning and Optimizing U-SQL Queries (SQLPASS 2016)
Tuning and Optimizing U-SQL Queries (SQLPASS 2016)Tuning and Optimizing U-SQL Queries (SQLPASS 2016)
Tuning and Optimizing U-SQL Queries (SQLPASS 2016)Michael Rys
 
3 CityNetConf - sql+c#=u-sql
3 CityNetConf - sql+c#=u-sql3 CityNetConf - sql+c#=u-sql
3 CityNetConf - sql+c#=u-sqlŁukasz Grala
 
Getting Strated with Amazon Dynamo DB (Jim Scharf) - AWS DB Day
Getting Strated with Amazon Dynamo DB (Jim Scharf) - AWS DB DayGetting Strated with Amazon Dynamo DB (Jim Scharf) - AWS DB Day
Getting Strated with Amazon Dynamo DB (Jim Scharf) - AWS DB DayAmazon Web Services Korea
 
Db2 sql tuning and bmc catalog manager
Db2 sql tuning and bmc catalog manager Db2 sql tuning and bmc catalog manager
Db2 sql tuning and bmc catalog manager Krishan Singh
 
Presentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cPresentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cRonald Francisco Vargas Quesada
 
SQL Server 2016 novelties
SQL Server 2016 noveltiesSQL Server 2016 novelties
SQL Server 2016 noveltiesMSDEVMTL
 
Best Practices for Supercharging Cloud Analytics on Amazon Redshift
Best Practices for Supercharging Cloud Analytics on Amazon RedshiftBest Practices for Supercharging Cloud Analytics on Amazon Redshift
Best Practices for Supercharging Cloud Analytics on Amazon RedshiftSnapLogic
 
AWS re:Invent 2016| DAT318 | Migrating from RDBMS to NoSQL: How Sony Moved fr...
AWS re:Invent 2016| DAT318 | Migrating from RDBMS to NoSQL: How Sony Moved fr...AWS re:Invent 2016| DAT318 | Migrating from RDBMS to NoSQL: How Sony Moved fr...
AWS re:Invent 2016| DAT318 | Migrating from RDBMS to NoSQL: How Sony Moved fr...Amazon Web Services
 
Overview of query evaluation
Overview of query evaluationOverview of query evaluation
Overview of query evaluationavniS
 
U-SQL - Azure Data Lake Analytics for Developers
U-SQL - Azure Data Lake Analytics for DevelopersU-SQL - Azure Data Lake Analytics for Developers
U-SQL - Azure Data Lake Analytics for DevelopersMichael Rys
 
SQL Server 2008 Development for Programmers
SQL Server 2008 Development for ProgrammersSQL Server 2008 Development for Programmers
SQL Server 2008 Development for ProgrammersAdam Hutson
 
Columnstore improvements in SQL Server 2016
Columnstore improvements in SQL Server 2016Columnstore improvements in SQL Server 2016
Columnstore improvements in SQL Server 2016Niko Neugebauer
 
Sql 2016 - What's New
Sql 2016 - What's NewSql 2016 - What's New
Sql 2016 - What's Newdpcobb
 
AWS Webcast - Build high-scale applications with Amazon DynamoDB
AWS Webcast - Build high-scale applications with Amazon DynamoDBAWS Webcast - Build high-scale applications with Amazon DynamoDB
AWS Webcast - Build high-scale applications with Amazon DynamoDBAmazon Web Services
 
Brad McGehee Intepreting Execution Plans Mar09
Brad McGehee Intepreting Execution Plans Mar09Brad McGehee Intepreting Execution Plans Mar09
Brad McGehee Intepreting Execution Plans Mar09Mark Ginnebaugh
 
A Metadata-Driven Approach to Computing Financial Analytics in a Relational D...
A Metadata-Driven Approach to Computing Financial Analytics in a Relational D...A Metadata-Driven Approach to Computing Financial Analytics in a Relational D...
A Metadata-Driven Approach to Computing Financial Analytics in a Relational D...inscit2006
 
Self-serve analytics journey at Celtra: Snowflake, Spark, and Databricks
Self-serve analytics journey at Celtra: Snowflake, Spark, and DatabricksSelf-serve analytics journey at Celtra: Snowflake, Spark, and Databricks
Self-serve analytics journey at Celtra: Snowflake, Spark, and DatabricksGrega Kespret
 

Semelhante a SQL Pass Summit Presentations from Datavail - Optimize SQL Server: Query Tuning Techniques (20)

Tuning and Optimizing U-SQL Queries (SQLPASS 2016)
Tuning and Optimizing U-SQL Queries (SQLPASS 2016)Tuning and Optimizing U-SQL Queries (SQLPASS 2016)
Tuning and Optimizing U-SQL Queries (SQLPASS 2016)
 
3 CityNetConf - sql+c#=u-sql
3 CityNetConf - sql+c#=u-sql3 CityNetConf - sql+c#=u-sql
3 CityNetConf - sql+c#=u-sql
 
Getting Strated with Amazon Dynamo DB (Jim Scharf) - AWS DB Day
Getting Strated with Amazon Dynamo DB (Jim Scharf) - AWS DB DayGetting Strated with Amazon Dynamo DB (Jim Scharf) - AWS DB Day
Getting Strated with Amazon Dynamo DB (Jim Scharf) - AWS DB Day
 
Db2 sql tuning and bmc catalog manager
Db2 sql tuning and bmc catalog manager Db2 sql tuning and bmc catalog manager
Db2 sql tuning and bmc catalog manager
 
Exploring T-SQL Anti-Patterns
Exploring T-SQL Anti-Patterns Exploring T-SQL Anti-Patterns
Exploring T-SQL Anti-Patterns
 
Presentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cPresentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12c
 
SQL Server 2016 novelties
SQL Server 2016 noveltiesSQL Server 2016 novelties
SQL Server 2016 novelties
 
Best Practices for Supercharging Cloud Analytics on Amazon Redshift
Best Practices for Supercharging Cloud Analytics on Amazon RedshiftBest Practices for Supercharging Cloud Analytics on Amazon Redshift
Best Practices for Supercharging Cloud Analytics on Amazon Redshift
 
AWS re:Invent 2016| DAT318 | Migrating from RDBMS to NoSQL: How Sony Moved fr...
AWS re:Invent 2016| DAT318 | Migrating from RDBMS to NoSQL: How Sony Moved fr...AWS re:Invent 2016| DAT318 | Migrating from RDBMS to NoSQL: How Sony Moved fr...
AWS re:Invent 2016| DAT318 | Migrating from RDBMS to NoSQL: How Sony Moved fr...
 
Overview of query evaluation
Overview of query evaluationOverview of query evaluation
Overview of query evaluation
 
Taming the shrew Power BI
Taming the shrew Power BITaming the shrew Power BI
Taming the shrew Power BI
 
U-SQL - Azure Data Lake Analytics for Developers
U-SQL - Azure Data Lake Analytics for DevelopersU-SQL - Azure Data Lake Analytics for Developers
U-SQL - Azure Data Lake Analytics for Developers
 
SQL Server 2008 Development for Programmers
SQL Server 2008 Development for ProgrammersSQL Server 2008 Development for Programmers
SQL Server 2008 Development for Programmers
 
Columnstore improvements in SQL Server 2016
Columnstore improvements in SQL Server 2016Columnstore improvements in SQL Server 2016
Columnstore improvements in SQL Server 2016
 
Sql 2016 - What's New
Sql 2016 - What's NewSql 2016 - What's New
Sql 2016 - What's New
 
AWS Webcast - Build high-scale applications with Amazon DynamoDB
AWS Webcast - Build high-scale applications with Amazon DynamoDBAWS Webcast - Build high-scale applications with Amazon DynamoDB
AWS Webcast - Build high-scale applications with Amazon DynamoDB
 
Brad McGehee Intepreting Execution Plans Mar09
Brad McGehee Intepreting Execution Plans Mar09Brad McGehee Intepreting Execution Plans Mar09
Brad McGehee Intepreting Execution Plans Mar09
 
A Metadata-Driven Approach to Computing Financial Analytics in a Relational D...
A Metadata-Driven Approach to Computing Financial Analytics in a Relational D...A Metadata-Driven Approach to Computing Financial Analytics in a Relational D...
A Metadata-Driven Approach to Computing Financial Analytics in a Relational D...
 
Self-serve analytics journey at Celtra: Snowflake, Spark, and Databricks
Self-serve analytics journey at Celtra: Snowflake, Spark, and DatabricksSelf-serve analytics journey at Celtra: Snowflake, Spark, and Databricks
Self-serve analytics journey at Celtra: Snowflake, Spark, and Databricks
 
Database testing
Database testingDatabase testing
Database testing
 

Mais de Datavail

Journey to Cloud Analytics
Journey to Cloud Analytics Journey to Cloud Analytics
Journey to Cloud Analytics Datavail
 
Accelerate SQL Server Migration to the AWS Cloud
Accelerate SQL Server Migration to the AWS Cloud Accelerate SQL Server Migration to the AWS Cloud
Accelerate SQL Server Migration to the AWS Cloud Datavail
 
MOUS 2020 - Hyperion 11.2 vs. Cloud: Should I Stay or Should I Go?
MOUS 2020 - Hyperion 11.2 vs. Cloud: Should I Stay or Should I Go?MOUS 2020 - Hyperion 11.2 vs. Cloud: Should I Stay or Should I Go?
MOUS 2020 - Hyperion 11.2 vs. Cloud: Should I Stay or Should I Go?Datavail
 
Oracle Enterprise Manager Seven Robust Features to Put in Action final
Oracle Enterprise Manager Seven Robust Features to Put in Action finalOracle Enterprise Manager Seven Robust Features to Put in Action final
Oracle Enterprise Manager Seven Robust Features to Put in Action finalDatavail
 
Lessons from Migrating Oracle Databases to Amazon RDS or Amazon Aurora
Lessons from Migrating Oracle Databases to Amazon RDS or Amazon Aurora Lessons from Migrating Oracle Databases to Amazon RDS or Amazon Aurora
Lessons from Migrating Oracle Databases to Amazon RDS or Amazon Aurora Datavail
 
EPM 11.2: Lessons Learned and 2021 Preparedness
EPM 11.2: Lessons Learned and 2021 PreparednessEPM 11.2: Lessons Learned and 2021 Preparedness
EPM 11.2: Lessons Learned and 2021 PreparednessDatavail
 
Optimizing Oracle Databases & Applications Gives Fast Food Giant Major Gains
Optimizing Oracle Databases & Applications Gives Fast Food Giant Major GainsOptimizing Oracle Databases & Applications Gives Fast Food Giant Major Gains
Optimizing Oracle Databases & Applications Gives Fast Food Giant Major GainsDatavail
 
RMOUG 2020: Keeping Pace with Change
RMOUG 2020: Keeping Pace with Change RMOUG 2020: Keeping Pace with Change
RMOUG 2020: Keeping Pace with Change Datavail
 
Upcoming Extended Support Deadlines & What They Mean for You
Upcoming Extended Support Deadlines & What They Mean for YouUpcoming Extended Support Deadlines & What They Mean for You
Upcoming Extended Support Deadlines & What They Mean for YouDatavail
 
SQL on Linux
SQL on LinuxSQL on Linux
SQL on LinuxDatavail
 
Reduce Cost by Tuning Queries on Azure DBaaS
Reduce Cost by Tuning Queries on Azure DBaaSReduce Cost by Tuning Queries on Azure DBaaS
Reduce Cost by Tuning Queries on Azure DBaaSDatavail
 
MOUS 2019 - Keeping Pace with Change: Prepare for Tomorrow & Advance Your Car...
MOUS 2019 - Keeping Pace with Change: Prepare for Tomorrow & Advance Your Car...MOUS 2019 - Keeping Pace with Change: Prepare for Tomorrow & Advance Your Car...
MOUS 2019 - Keeping Pace with Change: Prepare for Tomorrow & Advance Your Car...Datavail
 
Essbase On-Prem to Oracle Analytics Cloud - How, When, and Why
Essbase On-Prem to Oracle Analytics Cloud - How, When, and WhyEssbase On-Prem to Oracle Analytics Cloud - How, When, and Why
Essbase On-Prem to Oracle Analytics Cloud - How, When, and WhyDatavail
 
Is "Free" Good Enough for Your MySQL Environment?
Is "Free" Good Enough for Your MySQL Environment?Is "Free" Good Enough for Your MySQL Environment?
Is "Free" Good Enough for Your MySQL Environment?Datavail
 
Critical Preflight Checks for Your EPM Applications
Critical Preflight Checks for Your EPM ApplicationsCritical Preflight Checks for Your EPM Applications
Critical Preflight Checks for Your EPM ApplicationsDatavail
 
SQL to Azure Migrations
SQL to Azure MigrationsSQL to Azure Migrations
SQL to Azure MigrationsDatavail
 
Essbase On-Prem to Oracle Analytics Cloud - How, When, and Why
Essbase On-Prem to Oracle Analytics Cloud - How, When, and WhyEssbase On-Prem to Oracle Analytics Cloud - How, When, and Why
Essbase On-Prem to Oracle Analytics Cloud - How, When, and WhyDatavail
 
3 Ways to Lead an Accidental DBA
3 Ways to Lead an Accidental DBA3 Ways to Lead an Accidental DBA
3 Ways to Lead an Accidental DBADatavail
 
Creating a Solid EPM Punch List
Creating a Solid EPM Punch ListCreating a Solid EPM Punch List
Creating a Solid EPM Punch ListDatavail
 
Why NBC Universal Migrated to MongoDB Atlas
Why NBC Universal Migrated to MongoDB AtlasWhy NBC Universal Migrated to MongoDB Atlas
Why NBC Universal Migrated to MongoDB AtlasDatavail
 

Mais de Datavail (20)

Journey to Cloud Analytics
Journey to Cloud Analytics Journey to Cloud Analytics
Journey to Cloud Analytics
 
Accelerate SQL Server Migration to the AWS Cloud
Accelerate SQL Server Migration to the AWS Cloud Accelerate SQL Server Migration to the AWS Cloud
Accelerate SQL Server Migration to the AWS Cloud
 
MOUS 2020 - Hyperion 11.2 vs. Cloud: Should I Stay or Should I Go?
MOUS 2020 - Hyperion 11.2 vs. Cloud: Should I Stay or Should I Go?MOUS 2020 - Hyperion 11.2 vs. Cloud: Should I Stay or Should I Go?
MOUS 2020 - Hyperion 11.2 vs. Cloud: Should I Stay or Should I Go?
 
Oracle Enterprise Manager Seven Robust Features to Put in Action final
Oracle Enterprise Manager Seven Robust Features to Put in Action finalOracle Enterprise Manager Seven Robust Features to Put in Action final
Oracle Enterprise Manager Seven Robust Features to Put in Action final
 
Lessons from Migrating Oracle Databases to Amazon RDS or Amazon Aurora
Lessons from Migrating Oracle Databases to Amazon RDS or Amazon Aurora Lessons from Migrating Oracle Databases to Amazon RDS or Amazon Aurora
Lessons from Migrating Oracle Databases to Amazon RDS or Amazon Aurora
 
EPM 11.2: Lessons Learned and 2021 Preparedness
EPM 11.2: Lessons Learned and 2021 PreparednessEPM 11.2: Lessons Learned and 2021 Preparedness
EPM 11.2: Lessons Learned and 2021 Preparedness
 
Optimizing Oracle Databases & Applications Gives Fast Food Giant Major Gains
Optimizing Oracle Databases & Applications Gives Fast Food Giant Major GainsOptimizing Oracle Databases & Applications Gives Fast Food Giant Major Gains
Optimizing Oracle Databases & Applications Gives Fast Food Giant Major Gains
 
RMOUG 2020: Keeping Pace with Change
RMOUG 2020: Keeping Pace with Change RMOUG 2020: Keeping Pace with Change
RMOUG 2020: Keeping Pace with Change
 
Upcoming Extended Support Deadlines & What They Mean for You
Upcoming Extended Support Deadlines & What They Mean for YouUpcoming Extended Support Deadlines & What They Mean for You
Upcoming Extended Support Deadlines & What They Mean for You
 
SQL on Linux
SQL on LinuxSQL on Linux
SQL on Linux
 
Reduce Cost by Tuning Queries on Azure DBaaS
Reduce Cost by Tuning Queries on Azure DBaaSReduce Cost by Tuning Queries on Azure DBaaS
Reduce Cost by Tuning Queries on Azure DBaaS
 
MOUS 2019 - Keeping Pace with Change: Prepare for Tomorrow & Advance Your Car...
MOUS 2019 - Keeping Pace with Change: Prepare for Tomorrow & Advance Your Car...MOUS 2019 - Keeping Pace with Change: Prepare for Tomorrow & Advance Your Car...
MOUS 2019 - Keeping Pace with Change: Prepare for Tomorrow & Advance Your Car...
 
Essbase On-Prem to Oracle Analytics Cloud - How, When, and Why
Essbase On-Prem to Oracle Analytics Cloud - How, When, and WhyEssbase On-Prem to Oracle Analytics Cloud - How, When, and Why
Essbase On-Prem to Oracle Analytics Cloud - How, When, and Why
 
Is "Free" Good Enough for Your MySQL Environment?
Is "Free" Good Enough for Your MySQL Environment?Is "Free" Good Enough for Your MySQL Environment?
Is "Free" Good Enough for Your MySQL Environment?
 
Critical Preflight Checks for Your EPM Applications
Critical Preflight Checks for Your EPM ApplicationsCritical Preflight Checks for Your EPM Applications
Critical Preflight Checks for Your EPM Applications
 
SQL to Azure Migrations
SQL to Azure MigrationsSQL to Azure Migrations
SQL to Azure Migrations
 
Essbase On-Prem to Oracle Analytics Cloud - How, When, and Why
Essbase On-Prem to Oracle Analytics Cloud - How, When, and WhyEssbase On-Prem to Oracle Analytics Cloud - How, When, and Why
Essbase On-Prem to Oracle Analytics Cloud - How, When, and Why
 
3 Ways to Lead an Accidental DBA
3 Ways to Lead an Accidental DBA3 Ways to Lead an Accidental DBA
3 Ways to Lead an Accidental DBA
 
Creating a Solid EPM Punch List
Creating a Solid EPM Punch ListCreating a Solid EPM Punch List
Creating a Solid EPM Punch List
 
Why NBC Universal Migrated to MongoDB Atlas
Why NBC Universal Migrated to MongoDB AtlasWhy NBC Universal Migrated to MongoDB Atlas
Why NBC Universal Migrated to MongoDB Atlas
 

Último

Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfRachmat Ramadhan H
 
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改atducpo
 
BabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxBabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxolyaivanovalion
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxfirstjob4
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFxolyaivanovalion
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxolyaivanovalion
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfLars Albertsson
 
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一ffjhghh
 
Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxolyaivanovalion
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxolyaivanovalion
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...Suhani Kapoor
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysismanisha194592
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfMarinCaroMartnezBerg
 
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...apidays
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998YohFuh
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAroojKhan71
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionfulawalesam
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023ymrp368
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusTimothy Spann
 

Último (20)

Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
 
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
 
BabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxBabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptx
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptx
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFx
 
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptx
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdf
 
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一
 
Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFx
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysis
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
 
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...
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interaction
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and Milvus
 

SQL Pass Summit Presentations from Datavail - Optimize SQL Server: Query Tuning Techniques

  • 1. Query tuning techniques Rajnikant Tandel, DBA Manager, Datavail Anup Gopinathan, Sr. SQL Server DBA, Datavail Optimize SQL Server
  • 3. Free online webinar events Free 1-day local training events Local user groups around the world Online special interest user groups Business analytics training Get involved Explore everything PASS has to offer Free Online Resources Newsletters PASS.org
  • 4. Download the GuideBook App and search: PASS Summit 2018 Follow the QR code link displayed on session signage throughout the conference venue and in the program guide Session evaluations Your feedback is important and valuable. Go to passSummit.com 3 Ways to Access: Submit by 5pm Friday, November 16th to win prizes.
  • 5. Anup Gopinathan Sr. SQL Server DBA, Datavail Sr. DBA with over 11 years of experience in database design, development & administration and cloud computing. Extensive customer engagement experience, supported and worked with various customers. Database performance tuning Query tuning, execution plan analysis, index and statistics optimization. Database Scalability Table partitioning, analyze isolation and locking mechanisms, load balancing /anupgopinathannair @GopinathanAnup Powershell scripting and automations Cloud Data Architecture/Cloud Migration Design highly available and scalable database systems in cloud, migrate database from On- premises to cloud
  • 6. Rajnikant Tandel DBA Manager I’m a Microsoft Certified Solution Associate, SQL Server 2012/2014 and have over 15 years of SQL Server DBA experience on relational databases and application development and specialize in performance tuning, scalability and maintainability of large scale SQL Servers. I’ve worked extensively on performance tuning and query optimization projects. /rajnikant-tandel @tandelrajni Background • Programmer • Database Developer/DBA • Database Administrator • DBA Manager
  • 7. Datavail Overview Databases, Analytics, and Application Data Integration 13+ years delivering data services 300+ customers with average client retention of 7 years Managed services, projects, and staffing • All major platforms: SQL, Oracle, DB2, MySQL, Mongo DB • Comprehensive development & operational services • US & Global models • Reactive and proactive services Database Operations • Microsoft SSRS, SSIS, SSAS • PowerBI • Oracle OBIEE, BICS, Golden Gate • EBS • Hyperion/Essbase • Microsoft Dynamics • SharePoint • Custom development • Microsoft .NET • Oracle APEX Analytics, Visualization & Integration Application Management We are data specialists • Informatica • Oracle Data Integrator • ETL development and operational run
  • 8. Win Shoes Fill out the session survey for a chance to win an exclusive pair of Datavail’s running shoes!
  • 9. • T-SQL new functions and performance – How to use SQL Server 2017 new string functions to improve performance? • Lock Escalation – How? When? Why? • Table Variable V/S Temporary table V/S Correlated Subquery – compare performance. • Parameter sniffing – a look into how performance is affected. Agenda
  • 10. T-SQL new functions and performance Example: select category_code, STRING_AGG(category_desc, ', ') within group (order by category_desc) categories from category group by category_code category_code categories 1 Groceries, Lodging, Meals, Travel 2 Clothing, Communication, Electronics, Entertainment, Home Supplies, Misc STRING_AGG() Concatenates the values of string expressions and places separator values between them. The separator is not added at the end of string.
  • 12. T-SQL new functions and performance TRANSLATE() Returns the string provided as a first argument after some characters specified in the second argument are translated into a destination set of characters. TRANSLATE (inputstring, characters, translations) Example: SELECT TRANSLATE('2*[3+4]/{7-2}', '[]{}', '()()’); Output: 2*(3+4)/(7-2)
  • 14. T-SQL new functions and performance Summary • STRING_AGG() or TRANSLATE() perform better than user defined function or other T-SQL methods • Use CAST() when get an error “STRING_AGG aggregation result exceeded the limit of 8000 bytes.” • Consider replacing user defined function with new T-SQL functions
  • 16. Lock Escalation The process of acquiring higher level lock instead of many smaller locks is called lock escalation.
  • 17. How does escalation happen? 1250 5000 Row locks Page Lock Table lock
  • 18. Can we disable the lock escalation? Table hints • Row lock • Page lock ALTER TABLE CHARGE SET (LOCK_ESCALATION = TABLE | DISABLE | AUTO) • TABLE • DISABLE • AUTO There are some options available to control it.
  • 20. Summary • Lock escalation can be controlled by using table hints and by disabling escalation at table level. • Understand the pros and cons of each method. • SQL Engine can still escalate • “TEST”
  • 22. Table Variable vs Temp Table vs Correlated Subquery Table Variable • Can only be accessed within the batch and scope in which they are declared • Stored in TempDB • Because of the well-defined scope, a table variable generally uses fewer resources than a temporary table. • No statistics-based recompiles • Dropped automatically DECLARE @Totalcharge AS TABLE (Charge_no INT, Amount money, Date_Inserted datetime) There’s comfort in knowing that everything is temporary.
  • 23. Table Variable vs Temp Table vs Correlated Subquery Temporary Table • Stored in TempDB • Can create Indexes • Deleting a Temporary Table • Automatically when connection is closed • Manually using DROP Table statement • Performs better with large number of rows create table #Totalcharge (Charge_no INT, Amount money, Date_Inserted datetime)
  • 24. Table Variable vs Temp Table vs Correlated Subquery Correlated Subquery • A correlated subquery is a SELECT statement nested inside another T-SQL statement, which contains a reference to one or more columns in the outer query. • The correlated subquery will be run once for each candidate row selected by the outer query. SELECT column1, column2, .... FROM table1 outer WHERE column1 operator (SELECT column1, column2 FROM table2 WHERE expr1 = outer.expr2);
  • 25. Table Variable vs Temp Table vs Correlated Subquery
  • 26. Table Variable vs Temp Table vs Correlated Subquery Summary • Table variable performs well for smaller set of rows • Low maintenance cost • No statistics-based recompiles • Temp Table performs better for larger result set • Can Create Indexes and Statistics • Correlated subquery can be inefficient because it evaluated once for each row processed by the outer query
  • 28. Parameter Sniffing The execution plan for stored procedures does not work well for some arguments.
  • 29. Is this a bug? Parameter sniffing is not a bug
  • 31. Summary • Recompile • OPTION (OPTIMIZE FOR (@VARIABLE=VALUE | UNKNOWN)) • Disable parameter sniffing using Trace Flag 4136 / Database Scoped Configuration • local variableIt is not a bug. • Analyze your workloads • Testing
  • 33. References • www.mssqltips.com • sqlmag.com • sqlservercentral • stackoverflow.com • Sqlserverperformance • Statisticsparser.com
  • 34. Thank You Rajnikant Tandel @tandelrajni Rajnikant.Tandel@datavail.com Anup Gopinathan @GopinathanAnup Anup.Gopinathan@datavail.com Learn more from Learn more from
  • 35. Win Shoes Fill out the session survey for a chance to win an exclusive pair of Datavail’s running shoes!