SlideShare a Scribd company logo
SQLSERVER PERFORMANCE
TUNING
Presenter: Trịnh Hồng Chương
AGENDA
About my company – ANS-ASIA, and me
About SQL Performance
Indexing
Rewrite query
SQLServer tools to improve performance.
ABOUT
100% subsidiary of ANS Japan
Address : 10F CMC Tower, Duy Tan Street
Foudation : November 2012
Employees : 30
Business function :Business function :
Software development
Enterprise system (100% Japanese customer up to now)
(Sales management system, Enterprise system for transportation
industry, Tuition management system for university...)
IT consulting
ABOUT ME
Name: Trinh Hong Chuong
Skill: 6 years experience in software development
(.Net (VB.Net, C#), T-SQL, PL-SQL, VBA)
Beginner in PHP, PostgreSQL
Interesting in: Reading book, listening music,
walking alone, travelling, ….walking alone, travelling, ….
SQL PERFORMANCE
Assess the problem and establish numeric values
that categorize acceptable behavior.
Measure the performance of the system before
modification.
Identify the part of the system that is critical for
improving the performance. This is called
the bottleneck.
improving the performance. This is called
the bottleneck.
Modify that part of the system to remove the
bottleneck.
Measure the performance of the system after
modification.
If the modification makes the performance better,
adopt it. If the modification makes the
performance worse, put it back the way it was.
WHAT’S INDEXING
Index is shortcuts to real data
Data type structure: B-Tree
Types of indexes: Clustered, Non-Clustered, XML
index, Fulltext index
WHY’S INDEXING
An index is used to speed up searching in the
database.
Indexes can be helpful for a variety of queries
that contain SELECT, UPDATE, DELETE, or
MERGE statements.
Less items in primary keyLess items in primary key
CLUSTERED INDEX
Clustered indexes sort and store the data rows in
the table or view based on their key values.
root
Id(from 1 to 4) Id(from 5 to 7)Id(from 1 to 4) Id(from 5 to 7)
Id 1
Name Bill
Dept Dev
Id 2
Name Jobs
Dept HR
Id 7
Name Gate
Dept R&D
NON-CLUSTERED INDEX
A nonclustered index contains the nonclustered
index key values and each key value entry has a
pointer to the data row that contains the key
value.
root
Name(from A to F)
Name Bill
Id 1
Name Gate
Id 7
Name Jobs
Id 2
Name(from G to M) Name(from N to Z)
IMPROVE INDEX
Create Highly-Selective Indexes
Indexing on columns used in the WHERE clause of
your critical queries frequently improves
performance.
Selectivity is the ratio of qualifying rows to total
rows. If the ratio is low, the index is highly selective.
Create Multiple-Column IndexesCreate Multiple-Column Indexes
REWRITE QUERY
Use a search argument (SARG)
SARG operators include =, >, <, >=, <=, IN,
BETWEEN, and sometimes LIKE (in cases of prefix
matching, such as LIKE ‘Bill%')
Non-SARG operators include NOT, <>, NOT EXISTS,
NOT IN, NOT LIKE, and intrinsic functions
REWRITE QUERY
Rewrite sub-query into JOIN
Bad sample Good sample
SELECT "Order ID" SELECT DISTINCT O."Order ID"
FROM Orders O
WHERE EXISTS (SELECT "Order ID"
FROM "Order Details"
OD
WHERE O."Order ID" =
OD."Order ID"
AND Discount >= 0.25)
FROM Orders O
INNER JOIN "Order Details" OD
ON
O."Order ID" = OD."Order ID"
WHERE Discount >= 0.25
REWRITE QUERY
Don’t use intrinsic functions, type conversion on index column
Bad sample Good sample
DECLARE @limitId = 10
SELECT Name FROM
Employees
DECLARE @limitId = 10
SELECT Name FROM
EmployeesEmployees
WHERE Id - 1 = @limitId
Employees
WHERE Id = @limitId + 1
REWRITE QUERY
Use parameterizied queries
Query only you must
About Performance, cursor less than base-query
REWRITE QUERY
Index the ORDER-BY / GROUP-BY
CREATE INDEX Emp_Name ON Employees ("Last Name" ASC, "First Name" ASC)
Can help optimize Will not help optimize
... ORDER BY / GROUP BY "Last
Name" ...
... ORDER BY / GROUP BY
"First Name" ...Name" ...
... ORDER BY / GROUP BY "Last
Name", "First Name" ...
"First Name" ...
... ORDER BY / GROUP BY
"First Name", "Last Name" ...
REWRITE QUERY
Index the DISTINCT
CREATE INDEX Emp_Name ON Employees ("Last Name" ASC, "First Name" ASC)
Can help optimize Will not help optimize
... DISTINCT "Last Name", "First
Name" ...
... DISTINCT "First Name" ...
... DISTINCT "Last Name" ...Name" ...
... DISTINCT "First Name", "Last
Name" ...
... DISTINCT "Last Name" ...
SQLServer tools to improve performance.
Execution plan
CREATE TABLE Employees
(
Id BIGINT NOT NULL,
Name VARCHAR(20) NOT NULL,
Dept VARCHAR(10),
CONSTRAINT [PK_Employee] PRIMARY KEY
CLUSTERED
(Id ASC)
)
CREATE TABLE Employees_Mid
(
Id BIGINT NOT NULL,
Name VARCHAR(20) NOT NULL,
Dept VARCHAR(10),
CONSTRAINT [PK_Employee_Mid] PRIMARY KEY
CLUSTERED
(Id ASC)
)
Query 01
INSERT INTO Employees(Id, Name, Dept)
SELECT Id, Name, Dept FROM Employees_Mid
WHERE Employees_Mid.Id = 1000
Query 02
INSERT INTO Employees(Id, Name, Dept)
SELECT Id, Name, Dept FROM Employees_Mid
WHERE Employees_Mid.Name = ‘A00001’
EXECUTION PLAN – QUERY 01
EXECUTION PLAN – QUERY 02
SQLServer tools to improve performance.
SQL Profiler
REFERENCE
http://technet.microsoft.com
http://www.sqlviet.com
SQA server performance tuning

More Related Content

What's hot

Dare to build vertical design with relational data (Entity-Attribute-Value)
Dare to build vertical design with relational data (Entity-Attribute-Value)Dare to build vertical design with relational data (Entity-Attribute-Value)
Dare to build vertical design with relational data (Entity-Attribute-Value)
Ivo Andreev
 
Extensible Data Modeling
Extensible Data ModelingExtensible Data Modeling
Extensible Data Modeling
Karwin Software Solutions LLC
 
SQL select statement and functions
SQL select statement and functionsSQL select statement and functions
SQL select statement and functionsVikas Gupta
 
Advanced Sql Training
Advanced Sql TrainingAdvanced Sql Training
Advanced Sql Training
bixxman
 
Ch04
Ch04Ch04
Ch04
cs19club
 
Lesson01 学会使用基本的SQL语句
Lesson01 学会使用基本的SQL语句Lesson01 学会使用基本的SQL语句
Lesson01 学会使用基本的SQL语句
renguzi
 
Ch05
Ch05Ch05
Ch05
cs19club
 
Module 3
Module 3Module 3
Module 3
cs19club
 
Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)
Achmad Solichin
 
Aggregate Functions,Final
Aggregate Functions,FinalAggregate Functions,Final
Aggregate Functions,Final
mukesh24pandey
 
Sql server select queries ppt 18
Sql server select queries ppt 18Sql server select queries ppt 18
Sql server select queries ppt 18
Vibrant Technologies & Computers
 
Consultas con agrupaci¾n de datos
Consultas con agrupaci¾n de datosConsultas con agrupaci¾n de datos
Consultas con agrupaci¾n de datos
Caleb Gutiérrez
 
SQL- Introduction to MySQL
SQL- Introduction to MySQLSQL- Introduction to MySQL
SQL- Introduction to MySQL
Vibrant Technologies & Computers
 

What's hot (15)

Dare to build vertical design with relational data (Entity-Attribute-Value)
Dare to build vertical design with relational data (Entity-Attribute-Value)Dare to build vertical design with relational data (Entity-Attribute-Value)
Dare to build vertical design with relational data (Entity-Attribute-Value)
 
Extensible Data Modeling
Extensible Data ModelingExtensible Data Modeling
Extensible Data Modeling
 
SQL select statement and functions
SQL select statement and functionsSQL select statement and functions
SQL select statement and functions
 
Advanced Sql Training
Advanced Sql TrainingAdvanced Sql Training
Advanced Sql Training
 
Ch04
Ch04Ch04
Ch04
 
Lesson01 学会使用基本的SQL语句
Lesson01 学会使用基本的SQL语句Lesson01 学会使用基本的SQL语句
Lesson01 学会使用基本的SQL语句
 
Ch05
Ch05Ch05
Ch05
 
Module 3
Module 3Module 3
Module 3
 
Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)
 
Aggregate Functions,Final
Aggregate Functions,FinalAggregate Functions,Final
Aggregate Functions,Final
 
Les02
Les02Les02
Les02
 
Sql server select queries ppt 18
Sql server select queries ppt 18Sql server select queries ppt 18
Sql server select queries ppt 18
 
Consultas con agrupaci¾n de datos
Consultas con agrupaci¾n de datosConsultas con agrupaci¾n de datos
Consultas con agrupaci¾n de datos
 
SQL- Introduction to MySQL
SQL- Introduction to MySQLSQL- Introduction to MySQL
SQL- Introduction to MySQL
 
Les01
Les01Les01
Les01
 

Viewers also liked

Performance Sql Server
Performance Sql ServerPerformance Sql Server
Performance Sql Server
jarlei
 
SQL Server – Performance e Tunning
SQL Server – Performance e TunningSQL Server – Performance e Tunning
SQL Server – Performance e Tunning
pt_programar
 
SQL Saturday 329 - Novo Cardinality Estimator do SQL Server 2014
SQL Saturday 329 - Novo Cardinality Estimator do SQL Server 2014SQL Saturday 329 - Novo Cardinality Estimator do SQL Server 2014
SQL Saturday 329 - Novo Cardinality Estimator do SQL Server 2014
Vitor Fava
 
Find and fix SQL Server performance problems faster
Find and fix SQL Server performance problems fasterFind and fix SQL Server performance problems faster
Find and fix SQL Server performance problems faster
SolarWinds
 
SQL Server Performance Tuning Baseline
SQL Server Performance Tuning BaselineSQL Server Performance Tuning Baseline
SQL Server Performance Tuning Baseline
► Supreme Mandal ◄
 
Sql server performance tuning
Sql server performance tuningSql server performance tuning
Sql server performance tuning
ngupt28
 
Database Performance Tuning Introduction
Database  Performance Tuning IntroductionDatabase  Performance Tuning Introduction
Database Performance Tuning Introduction
MyOnlineITCourses
 

Viewers also liked (7)

Performance Sql Server
Performance Sql ServerPerformance Sql Server
Performance Sql Server
 
SQL Server – Performance e Tunning
SQL Server – Performance e TunningSQL Server – Performance e Tunning
SQL Server – Performance e Tunning
 
SQL Saturday 329 - Novo Cardinality Estimator do SQL Server 2014
SQL Saturday 329 - Novo Cardinality Estimator do SQL Server 2014SQL Saturday 329 - Novo Cardinality Estimator do SQL Server 2014
SQL Saturday 329 - Novo Cardinality Estimator do SQL Server 2014
 
Find and fix SQL Server performance problems faster
Find and fix SQL Server performance problems fasterFind and fix SQL Server performance problems faster
Find and fix SQL Server performance problems faster
 
SQL Server Performance Tuning Baseline
SQL Server Performance Tuning BaselineSQL Server Performance Tuning Baseline
SQL Server Performance Tuning Baseline
 
Sql server performance tuning
Sql server performance tuningSql server performance tuning
Sql server performance tuning
 
Database Performance Tuning Introduction
Database  Performance Tuning IntroductionDatabase  Performance Tuning Introduction
Database Performance Tuning Introduction
 

Similar to SQA server performance tuning

Veri Ambarları için Oracle'ın Analitik SQL Desteği
Veri Ambarları için Oracle'ın Analitik SQL DesteğiVeri Ambarları için Oracle'ın Analitik SQL Desteği
Veri Ambarları için Oracle'ın Analitik SQL Desteği
Emrah METE
 
MySQL Optimizer: What’s New in 8.0
MySQL Optimizer: What’s New in 8.0MySQL Optimizer: What’s New in 8.0
MySQL Optimizer: What’s New in 8.0
oysteing
 
SQL Tunning
SQL TunningSQL Tunning
SQL Tunning
Dhananjay Goel
 
MySQL Performance Optimization
MySQL Performance OptimizationMySQL Performance Optimization
MySQL Performance Optimization
Mindfire Solutions
 
SQL Server 2000 Research Series - Performance Tuning
SQL Server 2000 Research Series - Performance TuningSQL Server 2000 Research Series - Performance Tuning
SQL Server 2000 Research Series - Performance TuningJerry Yang
 
Brad McGehee Intepreting Execution Plans Mar09
Brad McGehee Intepreting Execution Plans Mar09Brad McGehee Intepreting Execution Plans Mar09
Brad McGehee Intepreting Execution Plans Mar09
guest9d79e073
 
Brad McGehee Intepreting Execution Plans Mar09
Brad McGehee Intepreting Execution Plans Mar09Brad McGehee Intepreting Execution Plans Mar09
Brad McGehee Intepreting Execution Plans Mar09
Mark Ginnebaugh
 
The Key to Keys - Database Design
The Key to Keys - Database DesignThe Key to Keys - Database Design
The Key to Keys - Database Design
Karen Lopez
 
Steps towards of sql server developer
Steps towards of sql server developerSteps towards of sql server developer
Steps towards of sql server developer
Ahsan Kabir
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
amitabros
 
UNIT 2 Structured query language commands
UNIT 2 Structured query language commandsUNIT 2 Structured query language commands
UNIT 2 Structured query language commands
Bhakti Pawar
 
Advanced SQL For Data Scientists
Advanced SQL For Data ScientistsAdvanced SQL For Data Scientists
Advanced SQL For Data Scientists
Databricks
 
Data Manipulation Language.pptx
Data Manipulation Language.pptxData Manipulation Language.pptx
Data Manipulation Language.pptx
EllenGracePorras
 
MIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome MeasuresMIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome Measures
Steven Johnson
 
SQL Server 2000 Research Series - Transact SQL
SQL Server 2000 Research Series - Transact SQLSQL Server 2000 Research Series - Transact SQL
SQL Server 2000 Research Series - Transact SQLJerry Yang
 
Sql Patterns
Sql PatternsSql Patterns
Sql Patternsphanleson
 
Database queries
Database queriesDatabase queries
Database queries
laiba29012
 
MDI Training DB2 Course
MDI Training DB2 CourseMDI Training DB2 Course
MDI Training DB2 CourseMarcus Davage
 
Get started with R lang
Get started with R langGet started with R lang
Get started with R lang
senthil0809
 
San diegophp
San diegophpSan diegophp
San diegophp
Dave Stokes
 

Similar to SQA server performance tuning (20)

Veri Ambarları için Oracle'ın Analitik SQL Desteği
Veri Ambarları için Oracle'ın Analitik SQL DesteğiVeri Ambarları için Oracle'ın Analitik SQL Desteği
Veri Ambarları için Oracle'ın Analitik SQL Desteği
 
MySQL Optimizer: What’s New in 8.0
MySQL Optimizer: What’s New in 8.0MySQL Optimizer: What’s New in 8.0
MySQL Optimizer: What’s New in 8.0
 
SQL Tunning
SQL TunningSQL Tunning
SQL Tunning
 
MySQL Performance Optimization
MySQL Performance OptimizationMySQL Performance Optimization
MySQL Performance Optimization
 
SQL Server 2000 Research Series - Performance Tuning
SQL Server 2000 Research Series - Performance TuningSQL Server 2000 Research Series - Performance Tuning
SQL Server 2000 Research Series - 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
 
Brad McGehee Intepreting Execution Plans Mar09
Brad McGehee Intepreting Execution Plans Mar09Brad McGehee Intepreting Execution Plans Mar09
Brad McGehee Intepreting Execution Plans Mar09
 
The Key to Keys - Database Design
The Key to Keys - Database DesignThe Key to Keys - Database Design
The Key to Keys - Database Design
 
Steps towards of sql server developer
Steps towards of sql server developerSteps towards of sql server developer
Steps towards of sql server developer
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
 
UNIT 2 Structured query language commands
UNIT 2 Structured query language commandsUNIT 2 Structured query language commands
UNIT 2 Structured query language commands
 
Advanced SQL For Data Scientists
Advanced SQL For Data ScientistsAdvanced SQL For Data Scientists
Advanced SQL For Data Scientists
 
Data Manipulation Language.pptx
Data Manipulation Language.pptxData Manipulation Language.pptx
Data Manipulation Language.pptx
 
MIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome MeasuresMIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome Measures
 
SQL Server 2000 Research Series - Transact SQL
SQL Server 2000 Research Series - Transact SQLSQL Server 2000 Research Series - Transact SQL
SQL Server 2000 Research Series - Transact SQL
 
Sql Patterns
Sql PatternsSql Patterns
Sql Patterns
 
Database queries
Database queriesDatabase queries
Database queries
 
MDI Training DB2 Course
MDI Training DB2 CourseMDI Training DB2 Course
MDI Training DB2 Course
 
Get started with R lang
Get started with R langGet started with R lang
Get started with R lang
 
San diegophp
San diegophpSan diegophp
San diegophp
 

More from Duy Tan Geek

Amazon Elastic Load Balancing
Amazon Elastic Load BalancingAmazon Elastic Load Balancing
Amazon Elastic Load BalancingDuy Tan Geek
 
Cloud - FOSS & Challenge
Cloud - FOSS & ChallengeCloud - FOSS & Challenge
Cloud - FOSS & ChallengeDuy Tan Geek
 
AWS, is it interesting?
AWS, is it interesting?AWS, is it interesting?
AWS, is it interesting?Duy Tan Geek
 
Cloud DC Transforming
Cloud DC TransformingCloud DC Transforming
Cloud DC TransformingDuy Tan Geek
 
Becoming a better programmer - unit testing
Becoming a better programmer - unit testingBecoming a better programmer - unit testing
Becoming a better programmer - unit testingDuy Tan Geek
 
Practical TDD in Septeni Technology
Practical TDD in Septeni TechnologyPractical TDD in Septeni Technology
Practical TDD in Septeni TechnologyDuy Tan Geek
 
Build Quality In with TDD
Build Quality In with TDDBuild Quality In with TDD
Build Quality In with TDDDuy Tan Geek
 
Sharing bridge SE working experience of myself
Sharing bridge SE working experience of myselfSharing bridge SE working experience of myself
Sharing bridge SE working experience of myselfDuy Tan Geek
 
Game development with Cocos2d-x Engine
Game development with Cocos2d-x EngineGame development with Cocos2d-x Engine
Game development with Cocos2d-x EngineDuy Tan Geek
 
HTML5 mobile games
HTML5 mobile gamesHTML5 mobile games
HTML5 mobile gamesDuy Tan Geek
 
Game engine introduction and approach
Game engine introduction and approachGame engine introduction and approach
Game engine introduction and approachDuy Tan Geek
 
10 things you need to know about doing business with Japanese
10 things you need to know about doing business with Japanese10 things you need to know about doing business with Japanese
10 things you need to know about doing business with JapaneseDuy Tan Geek
 
Enjoy Japanese work style
Enjoy Japanese work styleEnjoy Japanese work style
Enjoy Japanese work styleDuy Tan Geek
 
A cup of coffee worth 10 dollars is what we are going to sell!
A cup of coffee worth 10 dollars is what we are going to sell!A cup of coffee worth 10 dollars is what we are going to sell!
A cup of coffee worth 10 dollars is what we are going to sell!Duy Tan Geek
 
Introduction to pmp
Introduction to pmpIntroduction to pmp
Introduction to pmpDuy Tan Geek
 
Beyond project management
Beyond project managementBeyond project management
Beyond project managementDuy Tan Geek
 
The way to set automation testing
The way to set automation testingThe way to set automation testing
The way to set automation testingDuy Tan Geek
 
Quality Management Introduction
Quality Management IntroductionQuality Management Introduction
Quality Management IntroductionDuy Tan Geek
 
Techniques in black box testing
Techniques in black box testingTechniques in black box testing
Techniques in black box testingDuy Tan Geek
 

More from Duy Tan Geek (20)

Amazon Elastic Load Balancing
Amazon Elastic Load BalancingAmazon Elastic Load Balancing
Amazon Elastic Load Balancing
 
Cloud - FOSS & Challenge
Cloud - FOSS & ChallengeCloud - FOSS & Challenge
Cloud - FOSS & Challenge
 
AWS, is it interesting?
AWS, is it interesting?AWS, is it interesting?
AWS, is it interesting?
 
Cloud DC Transforming
Cloud DC TransformingCloud DC Transforming
Cloud DC Transforming
 
Becoming a better programmer - unit testing
Becoming a better programmer - unit testingBecoming a better programmer - unit testing
Becoming a better programmer - unit testing
 
Practical TDD in Septeni Technology
Practical TDD in Septeni TechnologyPractical TDD in Septeni Technology
Practical TDD in Septeni Technology
 
Build Quality In with TDD
Build Quality In with TDDBuild Quality In with TDD
Build Quality In with TDD
 
Sharing bridge SE working experience of myself
Sharing bridge SE working experience of myselfSharing bridge SE working experience of myself
Sharing bridge SE working experience of myself
 
Game development with Cocos2d-x Engine
Game development with Cocos2d-x EngineGame development with Cocos2d-x Engine
Game development with Cocos2d-x Engine
 
HTML5 mobile games
HTML5 mobile gamesHTML5 mobile games
HTML5 mobile games
 
Game engine introduction and approach
Game engine introduction and approachGame engine introduction and approach
Game engine introduction and approach
 
10 things you need to know about doing business with Japanese
10 things you need to know about doing business with Japanese10 things you need to know about doing business with Japanese
10 things you need to know about doing business with Japanese
 
Enjoy Japanese work style
Enjoy Japanese work styleEnjoy Japanese work style
Enjoy Japanese work style
 
A cup of coffee worth 10 dollars is what we are going to sell!
A cup of coffee worth 10 dollars is what we are going to sell!A cup of coffee worth 10 dollars is what we are going to sell!
A cup of coffee worth 10 dollars is what we are going to sell!
 
Leader ship value
Leader ship valueLeader ship value
Leader ship value
 
Introduction to pmp
Introduction to pmpIntroduction to pmp
Introduction to pmp
 
Beyond project management
Beyond project managementBeyond project management
Beyond project management
 
The way to set automation testing
The way to set automation testingThe way to set automation testing
The way to set automation testing
 
Quality Management Introduction
Quality Management IntroductionQuality Management Introduction
Quality Management Introduction
 
Techniques in black box testing
Techniques in black box testingTechniques in black box testing
Techniques in black box testing
 

Recently uploaded

Nanandann Nilekani's ppt On India's .pdf
Nanandann Nilekani's ppt On India's .pdfNanandann Nilekani's ppt On India's .pdf
Nanandann Nilekani's ppt On India's .pdf
eddie19851
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP
 
My burning issue is homelessness K.C.M.O.
My burning issue is homelessness K.C.M.O.My burning issue is homelessness K.C.M.O.
My burning issue is homelessness K.C.M.O.
rwarrenll
 
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
mbawufebxi
 
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
AbhimanyuSinha9
 
Influence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business PlanInfluence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business Plan
jerlynmaetalle
 
The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...
jerlynmaetalle
 
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
axoqas
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Subhajit Sahu
 
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
oz8q3jxlp
 
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
dwreak4tg
 
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
John Andrews
 
Adjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTESAdjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTES
Subhajit Sahu
 
Data_and_Analytics_Essentials_Architect_an_Analytics_Platform.pptx
Data_and_Analytics_Essentials_Architect_an_Analytics_Platform.pptxData_and_Analytics_Essentials_Architect_an_Analytics_Platform.pptx
Data_and_Analytics_Essentials_Architect_an_Analytics_Platform.pptx
AnirbanRoy608946
 
Adjusting OpenMP PageRank : SHORT REPORT / NOTES
Adjusting OpenMP PageRank : SHORT REPORT / NOTESAdjusting OpenMP PageRank : SHORT REPORT / NOTES
Adjusting OpenMP PageRank : SHORT REPORT / NOTES
Subhajit Sahu
 
Everything you wanted to know about LIHTC
Everything you wanted to know about LIHTCEverything you wanted to know about LIHTC
Everything you wanted to know about LIHTC
Roger Valdez
 
Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)
TravisMalana
 
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
Timothy Spann
 
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
g4dpvqap0
 
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
v3tuleee
 

Recently uploaded (20)

Nanandann Nilekani's ppt On India's .pdf
Nanandann Nilekani's ppt On India's .pdfNanandann Nilekani's ppt On India's .pdf
Nanandann Nilekani's ppt On India's .pdf
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
 
My burning issue is homelessness K.C.M.O.
My burning issue is homelessness K.C.M.O.My burning issue is homelessness K.C.M.O.
My burning issue is homelessness K.C.M.O.
 
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
 
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
 
Influence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business PlanInfluence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business Plan
 
The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...
 
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
 
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
 
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
 
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
 
Adjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTESAdjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTES
 
Data_and_Analytics_Essentials_Architect_an_Analytics_Platform.pptx
Data_and_Analytics_Essentials_Architect_an_Analytics_Platform.pptxData_and_Analytics_Essentials_Architect_an_Analytics_Platform.pptx
Data_and_Analytics_Essentials_Architect_an_Analytics_Platform.pptx
 
Adjusting OpenMP PageRank : SHORT REPORT / NOTES
Adjusting OpenMP PageRank : SHORT REPORT / NOTESAdjusting OpenMP PageRank : SHORT REPORT / NOTES
Adjusting OpenMP PageRank : SHORT REPORT / NOTES
 
Everything you wanted to know about LIHTC
Everything you wanted to know about LIHTCEverything you wanted to know about LIHTC
Everything you wanted to know about LIHTC
 
Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)
 
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
 
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
 
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
 

SQA server performance tuning

  • 2. AGENDA About my company – ANS-ASIA, and me About SQL Performance Indexing Rewrite query SQLServer tools to improve performance.
  • 3. ABOUT 100% subsidiary of ANS Japan Address : 10F CMC Tower, Duy Tan Street Foudation : November 2012 Employees : 30 Business function :Business function : Software development Enterprise system (100% Japanese customer up to now) (Sales management system, Enterprise system for transportation industry, Tuition management system for university...) IT consulting
  • 4. ABOUT ME Name: Trinh Hong Chuong Skill: 6 years experience in software development (.Net (VB.Net, C#), T-SQL, PL-SQL, VBA) Beginner in PHP, PostgreSQL Interesting in: Reading book, listening music, walking alone, travelling, ….walking alone, travelling, ….
  • 5. SQL PERFORMANCE Assess the problem and establish numeric values that categorize acceptable behavior. Measure the performance of the system before modification. Identify the part of the system that is critical for improving the performance. This is called the bottleneck. improving the performance. This is called the bottleneck. Modify that part of the system to remove the bottleneck. Measure the performance of the system after modification. If the modification makes the performance better, adopt it. If the modification makes the performance worse, put it back the way it was.
  • 6. WHAT’S INDEXING Index is shortcuts to real data Data type structure: B-Tree Types of indexes: Clustered, Non-Clustered, XML index, Fulltext index
  • 7. WHY’S INDEXING An index is used to speed up searching in the database. Indexes can be helpful for a variety of queries that contain SELECT, UPDATE, DELETE, or MERGE statements. Less items in primary keyLess items in primary key
  • 8. CLUSTERED INDEX Clustered indexes sort and store the data rows in the table or view based on their key values. root Id(from 1 to 4) Id(from 5 to 7)Id(from 1 to 4) Id(from 5 to 7) Id 1 Name Bill Dept Dev Id 2 Name Jobs Dept HR Id 7 Name Gate Dept R&D
  • 9. NON-CLUSTERED INDEX A nonclustered index contains the nonclustered index key values and each key value entry has a pointer to the data row that contains the key value. root Name(from A to F) Name Bill Id 1 Name Gate Id 7 Name Jobs Id 2 Name(from G to M) Name(from N to Z)
  • 10. IMPROVE INDEX Create Highly-Selective Indexes Indexing on columns used in the WHERE clause of your critical queries frequently improves performance. Selectivity is the ratio of qualifying rows to total rows. If the ratio is low, the index is highly selective. Create Multiple-Column IndexesCreate Multiple-Column Indexes
  • 11. REWRITE QUERY Use a search argument (SARG) SARG operators include =, >, <, >=, <=, IN, BETWEEN, and sometimes LIKE (in cases of prefix matching, such as LIKE ‘Bill%') Non-SARG operators include NOT, <>, NOT EXISTS, NOT IN, NOT LIKE, and intrinsic functions
  • 12. REWRITE QUERY Rewrite sub-query into JOIN Bad sample Good sample SELECT "Order ID" SELECT DISTINCT O."Order ID" FROM Orders O WHERE EXISTS (SELECT "Order ID" FROM "Order Details" OD WHERE O."Order ID" = OD."Order ID" AND Discount >= 0.25) FROM Orders O INNER JOIN "Order Details" OD ON O."Order ID" = OD."Order ID" WHERE Discount >= 0.25
  • 13. REWRITE QUERY Don’t use intrinsic functions, type conversion on index column Bad sample Good sample DECLARE @limitId = 10 SELECT Name FROM Employees DECLARE @limitId = 10 SELECT Name FROM EmployeesEmployees WHERE Id - 1 = @limitId Employees WHERE Id = @limitId + 1
  • 14. REWRITE QUERY Use parameterizied queries Query only you must About Performance, cursor less than base-query
  • 15. REWRITE QUERY Index the ORDER-BY / GROUP-BY CREATE INDEX Emp_Name ON Employees ("Last Name" ASC, "First Name" ASC) Can help optimize Will not help optimize ... ORDER BY / GROUP BY "Last Name" ... ... ORDER BY / GROUP BY "First Name" ...Name" ... ... ORDER BY / GROUP BY "Last Name", "First Name" ... "First Name" ... ... ORDER BY / GROUP BY "First Name", "Last Name" ...
  • 16. REWRITE QUERY Index the DISTINCT CREATE INDEX Emp_Name ON Employees ("Last Name" ASC, "First Name" ASC) Can help optimize Will not help optimize ... DISTINCT "Last Name", "First Name" ... ... DISTINCT "First Name" ... ... DISTINCT "Last Name" ...Name" ... ... DISTINCT "First Name", "Last Name" ... ... DISTINCT "Last Name" ...
  • 17. SQLServer tools to improve performance. Execution plan CREATE TABLE Employees ( Id BIGINT NOT NULL, Name VARCHAR(20) NOT NULL, Dept VARCHAR(10), CONSTRAINT [PK_Employee] PRIMARY KEY CLUSTERED (Id ASC) ) CREATE TABLE Employees_Mid ( Id BIGINT NOT NULL, Name VARCHAR(20) NOT NULL, Dept VARCHAR(10), CONSTRAINT [PK_Employee_Mid] PRIMARY KEY CLUSTERED (Id ASC) ) Query 01 INSERT INTO Employees(Id, Name, Dept) SELECT Id, Name, Dept FROM Employees_Mid WHERE Employees_Mid.Id = 1000 Query 02 INSERT INTO Employees(Id, Name, Dept) SELECT Id, Name, Dept FROM Employees_Mid WHERE Employees_Mid.Name = ‘A00001’
  • 18. EXECUTION PLAN – QUERY 01
  • 19. EXECUTION PLAN – QUERY 02
  • 20. SQLServer tools to improve performance. SQL Profiler