SlideShare a Scribd company logo
1 of 40
How to Use Parameters Like a Pro
and Boost Performance
How to Use Parameters Like a Pro
and Boost Performance
Name: Guy Glantser
Email Address: guy@madeira.co.il
Twitter: @guy_glantser
Blog: www.madeirasql.com/author/guyglantser
Podcast: www.sqlserverradio.com
Image courtesy of Mister GC / FreeDigitalPhotos.net
Let’s Begin
with a Story…
What is Parameterization?
Image courtesy of iosphere / FreeDigitalPhotos.net
Why is it So Important?
Image courtesy of iosphere / FreeDigitalPhotos.net
When does it Become
Problematic?
Image courtesy of iosphere / FreeDigitalPhotos.net
How can we Deal with it?
Image courtesy of iosphere / FreeDigitalPhotos.net
SELECT
ProductName ,
ProductCategory
FROM
Production.Product
WHERE
ProductID = 17;
SELECT
ProductName ,
ProductCategory
FROM
Production.Product
WHERE
ProductID = 17;
SELECT
ProductName ,
ProductCategory
FROM
Production.Product
WHERE
ProductID = 63;
SELECT
ProductName ,
ProductCategory
FROM
Production.Product
WHERE
ProductID = @ProductID;
Image courtesy of Salvatore Vuono / FreeDigitalPhotos.net
SELECT
Id ,
Name ,
LastPurchaseDate
FROM
Marketing.Customers
WHERE
Country = N'DK';
Image courtesy of Gualberto107 / FreeDigitalPhotos.net
Image courtesy of Stuart Miles / FreeDigitalPhotos.net
Image courtesy of Stuart Miles / FreeDigitalPhotos.net
Image courtesy of Stuart Miles / FreeDigitalPhotos.net
Is Parameter Sniffing
Good or Bad?
Image courtesy of Salvatore Vuono / FreeDigitalPhotos.net
Image courtesy of Salvatore Vuono / FreeDigitalPhotos.net
Database Level Query Template Level
Image courtesy of Stuart Miles & Master isolated images / FreeDigitalPhotos.net
Image courtesy of stockimages / FreeDigitalPhotos.net
Image courtesy of stockimages / FreeDigitalPhotos.net
Image courtesy of stockimages / FreeDigitalPhotos.net
Tip #1
Usually, data distribution is
more or less uniform, so, in
general, prefer parameterized
queries over non-
parameterized queries.
Image courtesy of stockimages / FreeDigitalPhotos.net
Tip #2
When data is not uniformly
distributed, rewrite your code
using one of the methods
shown in this session.
Image courtesy of stockimages / FreeDigitalPhotos.net
Tip #3
Avoid the use of local
variables as an alternative for
parameters.
Use parameters instead.
Image courtesy of stockimages / FreeDigitalPhotos.net
Tip #4
Don’t change parameter
values inside your stored
procedures.
Pass the calculated values to
inner stored procedures to
use parameter sniffing.
Image courtesy of stockimages / FreeDigitalPhotos.net
Tip #5
Force parameterization only
when you have no other
choice.
Prefer forced
parameterization at the
query template level.
Back to the Story…
http://www.madeirasql.com/tag/parameterization-series/
Image courtesy of Stuart Miles / FreeDigitalPhotos.net
Image courtesy of Master isolated images / FreeDigitalPhotos.net
Explore Everything PASS Has to Offer
Free SQL Server and BI Web Events Free 1-day Training Events Regional Event
Local User Groups Around
the World
Free Online Technical Training
This is Community Business Analytics Training
Session Recordings PASS Newsletter
Image courtesy of David Castillo Dominici / FreeDigitalPhotos.net
Name: Guy Glantser
Email Address: guy@madeira.co.il
Twitter: @guy_glantser
Blog: www.madeirasql.com/author/guyglantser
Podcast: www.sqlserverradio.com
Image courtesy of Mister GC / FreeDigitalPhotos.net

More Related Content

Viewers also liked

Vous vous imaginez comment dans dix ans.
Vous vous imaginez comment dans dix ans. Vous vous imaginez comment dans dix ans.
Vous vous imaginez comment dans dix ans.
Osoraptor
 
Strategies for dramatic cost reduction v2 june aus contact final
Strategies for dramatic cost reduction v2 june aus contact finalStrategies for dramatic cost reduction v2 june aus contact final
Strategies for dramatic cost reduction v2 june aus contact final
Enghouse Interactive
 

Viewers also liked (11)

Vous vous imaginez comment dans dix ans.
Vous vous imaginez comment dans dix ans. Vous vous imaginez comment dans dix ans.
Vous vous imaginez comment dans dix ans.
 
Strategies for dramatic cost reduction june aus contact final
Strategies for dramatic cost reduction june aus contact finalStrategies for dramatic cost reduction june aus contact final
Strategies for dramatic cost reduction june aus contact final
 
Strategies for dramatic cost reduction v2 june aus contact
Strategies for dramatic cost reduction v2 june aus contactStrategies for dramatic cost reduction v2 june aus contact
Strategies for dramatic cost reduction v2 june aus contact
 
Wendi Kellman-Janow Resume
Wendi Kellman-Janow ResumeWendi Kellman-Janow Resume
Wendi Kellman-Janow Resume
 
Strategies for dramatic cost reduction v2 june aus contact final
Strategies for dramatic cost reduction v2 june aus contact finalStrategies for dramatic cost reduction v2 june aus contact final
Strategies for dramatic cost reduction v2 june aus contact final
 
Enghouse Interactive Roadshow - Brisbane Customer Slides
Enghouse Interactive Roadshow - Brisbane Customer SlidesEnghouse Interactive Roadshow - Brisbane Customer Slides
Enghouse Interactive Roadshow - Brisbane Customer Slides
 
PRASENJIT SIKDER1
PRASENJIT SIKDER1PRASENJIT SIKDER1
PRASENJIT SIKDER1
 
PRASENJIT SIKDER1
PRASENJIT SIKDER1PRASENJIT SIKDER1
PRASENJIT SIKDER1
 
Stem pp for coaches meeting
Stem pp for coaches meetingStem pp for coaches meeting
Stem pp for coaches meeting
 
Enghouse Interactive:Top 5 trends in customer communications
Enghouse Interactive:Top 5 trends in customer communicationsEnghouse Interactive:Top 5 trends in customer communications
Enghouse Interactive:Top 5 trends in customer communications
 
Parts of the plant we eat
Parts of the plant we eatParts of the plant we eat
Parts of the plant we eat
 

Similar to How to use parameters like a pro and boost performance

Similar to How to use parameters like a pro and boost performance (20)

Django Introduction Osscamp Delhi September 08 09 2007 Mir Nazim
Django Introduction Osscamp Delhi September 08 09 2007 Mir NazimDjango Introduction Osscamp Delhi September 08 09 2007 Mir Nazim
Django Introduction Osscamp Delhi September 08 09 2007 Mir Nazim
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
How to get data with Google Tag Manager when developer is not available
How to get data with Google Tag Manager when developer is not availableHow to get data with Google Tag Manager when developer is not available
How to get data with Google Tag Manager when developer is not available
 
How to train your product owner
How to train your product ownerHow to train your product owner
How to train your product owner
 
When You Need Custom Data in GTM but a Developer is Not Available
When You Need Custom Data in GTM but a Developer is Not AvailableWhen You Need Custom Data in GTM but a Developer is Not Available
When You Need Custom Data in GTM but a Developer is Not Available
 
Applied Data Science: Building a Beer Recommender | Data Science MD - Oct 2014
Applied Data Science: Building a Beer Recommender | Data Science MD - Oct 2014Applied Data Science: Building a Beer Recommender | Data Science MD - Oct 2014
Applied Data Science: Building a Beer Recommender | Data Science MD - Oct 2014
 
How to Document Samples for FDA Detained Product
How to Document Samples for FDA Detained ProductHow to Document Samples for FDA Detained Product
How to Document Samples for FDA Detained Product
 
Secrets to Optimize Website Tracking for User Engagement
Secrets to Optimize Website Tracking for User EngagementSecrets to Optimize Website Tracking for User Engagement
Secrets to Optimize Website Tracking for User Engagement
 
Building a Beer Recommender with Yhat (PAPIs.io - November 2014)
Building a Beer Recommender with Yhat (PAPIs.io - November 2014)Building a Beer Recommender with Yhat (PAPIs.io - November 2014)
Building a Beer Recommender with Yhat (PAPIs.io - November 2014)
 
Kaggle and data science
Kaggle and data scienceKaggle and data science
Kaggle and data science
 
Google Analytics Powerups and Smartcuts
Google Analytics Powerups and Smartcuts Google Analytics Powerups and Smartcuts
Google Analytics Powerups and Smartcuts
 
Digital Marketing Bootcamp - Evaluating Marketing Automation
Digital Marketing Bootcamp - Evaluating Marketing AutomationDigital Marketing Bootcamp - Evaluating Marketing Automation
Digital Marketing Bootcamp - Evaluating Marketing Automation
 
Secrets to Optimize Website Tracking for User Engagement
Secrets to Optimize Website Tracking for User EngagementSecrets to Optimize Website Tracking for User Engagement
Secrets to Optimize Website Tracking for User Engagement
 
Jigoshop Presentation at WordPress London, April 2012
Jigoshop Presentation at WordPress London, April 2012Jigoshop Presentation at WordPress London, April 2012
Jigoshop Presentation at WordPress London, April 2012
 
Permettere al cliente di apprezzare l'approccio agile
Permettere al cliente di apprezzare l'approccio agilePermettere al cliente di apprezzare l'approccio agile
Permettere al cliente di apprezzare l'approccio agile
 
Tripletail
TripletailTripletail
Tripletail
 
Automate, Create Tools, & Test Ideas Quickly with Google Apps Script
Automate, Create Tools, & Test Ideas Quickly with Google Apps ScriptAutomate, Create Tools, & Test Ideas Quickly with Google Apps Script
Automate, Create Tools, & Test Ideas Quickly with Google Apps Script
 
Scaling Ride-Hailing with Machine Learning on MLflow
Scaling Ride-Hailing with Machine Learning on MLflowScaling Ride-Hailing with Machine Learning on MLflow
Scaling Ride-Hailing with Machine Learning on MLflow
 
Google Analytics location data visualised with CARTO & BigQuery
Google Analytics location data visualised with CARTO & BigQueryGoogle Analytics location data visualised with CARTO & BigQuery
Google Analytics location data visualised with CARTO & BigQuery
 
Top 5 Tools & Hacks to Optimize Your Offers for Success and 5 Benefits You Re...
Top 5 Tools & Hacks to Optimize Your Offers for Success and 5 Benefits You Re...Top 5 Tools & Hacks to Optimize Your Offers for Success and 5 Benefits You Re...
Top 5 Tools & Hacks to Optimize Your Offers for Success and 5 Benefits You Re...
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
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
 
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
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
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
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

How to use parameters like a pro and boost performance