SlideShare une entreprise Scribd logo
1  sur  63
Télécharger pour lire hors ligne
Uncovering SQL Server Query Problems with
Execution Plans
Tony Davis
tony.davis@red-gate.com
@tonytheeditor
#SQLintheCityUK
About Me
Books
SQL Server transaction log
SQL Server Source Control
Speaker
#SQLintheCityUK
SELECT ProductID ,
ProductNumber ,
dbo.LineItemTotal(ProductID)
AS SumTotal
FROM Production.Product p
GO
SELECT bth.ProductID ,
bth.TransactionDate ,
bth.Quantity ,
bth.ActualCost
FROM dbo.bigTransactionHistory bth
WHERE bth.TransactionDate >= '20100701'
AND bth.TransactionDate
<= CURRENT_TIMESTAMP
ORDER BY bth.TransactionDate DESC;
GO
Why Bother Learning Execution Plans?
WITH Totals
AS ( SELECT DATEADD(m, u.theMonth, 0) AS TheMonth ,
SUM(CASE WHEN u.theCol = 'DateJoined'
THEN u.Registrations
ELSE 0
END) AS PeopleJoined ,
SUM(CASE WHEN u.theCol = 'DateLeft'
THEN u.Registrations
ELSE 0
END) AS PeopleLeft
FROM ( SELECT DATEDIFF(MONTH, 0, DateJoined)
AS DateJoined ,
DATEDIFF(MONTH, 0, DateLeft)
AS DateLeft ,
COUNT(*) AS Registrations
FROM dbo.Registrations2
GROUP BY DATEDIFF(MONTH, 0, DateJoined) ,
DATEDIFF(MONTH, 0, DateLeft)
) AS d UNPIVOT ( theMonth FOR theCol
IN ( d.DateJoined,
d.DateLeft ) ) AS u
GROUP BY u.theMonth
HAVING SUM(CASE WHEN u.theCol = 'DateJoined'
THEN u.Registrations
ELSE 0
END) > 0
)
SELECT TheMonth ,
PeopleJoined ,
PeopleLeft ,
SUM(PeopleJoined - PeopleLeft) OVER ( ORDER BY TheMonth
ROWS UNBOUNDED PRECEDING ) AS CurrentSubscribers
FROM Totals;
From Query to Execution plan
SELECT bth.ProductID ,
bth.TransactionDate ,
bth.Quantity ,
bth.ActualCost
FROM dbo.bigTransactionHistory bth
WHERE bth.TransactionDate >= '20100701'
AND bth.TransactionDate <=
CURRENT_TIMESTAMP
ORDER BY bth.TransactionDate DESC;
GO
#SQLintheCityUK
Plan
1
Plan
2
Plan
3
Plan
4
Plan
57
Plan
n?
Algebrizer
(Query Binding)
Syntax Checking
(Query Parsing)
Query
Optimization
Plan
Query
Execution
Engine
Plan
Cache
Metadata
Table/index structures
SELECT bth.ProductID ,
bth.TransactionDate ,
bth.Quantity ,
bth.ActualCost
FROM dbo.bigTransactionHistory bth
WHERE bth.TransactionDate >= '20100701'
AND bth.TransactionDate <= CURRENT_TIMESTAMP
ORDER BY bth.TransactionDate DESC;
GO
Index/Column Statistics
Volume/distribution of data
#SQLintheCityUK
Getting the Execution Plan
.NET Code Profiler
- e.g. ANTS Performance Profiler
Get plans for previously executed
queries from the plan cache
- e.g. SQL Trace or Extended Events
- Using sys.dm_exec_cached_plans
Plans in cache contain no runtime
information

#SQLintheCityUK
#SQLintheCityUK
Getting the Execution Plan
.NET Code Profiler
- e.g. ANTS Performance Profiler
Get plans for previously executed
queries from the plan cache
- e.g. SQL Trace or Extended Events
- Using sys.dm_exec_cached_plans
Plans in cache contain no runtime
information
 SET
During testing, request the plan for
a query
• “estimated” plan – no runtime
• “actual” plan - with runtime
There is only 1 plan!

#SQLintheCityUK
#SQLintheCityUK
Execution Plans for Developers
• Don’t examine plan for every query
• Gather stats, focus on critical, frequent, resource-
intensive queries
• Sometimes the code logic is just wrong
– rip it up and start again!
• Sometimes the basic logic is fine
– But some subtler problem causes poor execution performance
– This is where execution plans can help!
#SQLintheCityUK
• With SQL Server:
• We submit SQL describing the data set we
want
• The Optimizer decides how to execute it
• Some developers bring imperative approach line-
by-line control to SQL Server…
Problem: Row-by-row strategy
#SQLintheCityUK
#SQLintheCityUK
#SQLintheCityUK
#SQLintheCityUK
#SQLintheCityUK
#SQLintheCityUK
#SQLintheCityUK
#SQLintheCityUK
#SQLintheCityUK
#SQLintheCityUK
#SQLintheCityUK
#SQLintheCityUK
#SQLintheCityUK
#SQLintheCityUK
#SQLintheCityUK
#SQLintheCityUK
#SQLintheCityUK
#SQLintheCityUK
#SQLintheCityUK
#SQLintheCityUK
#SQLintheCityUK
Solution: set-based approach
– Take the list to the supermarket ;)
– Define single statement (if possible) to return required
data set
• Make as few ‘passes’ through the base tables as possible
• Aggregate early
• Reduce the working set to as few rows as possible
#SQLintheCityUK
WITH Totals
AS ( SELECT DATEADD(m, u.theMonth, 0) AS TheMonth ,
SUM(CASE WHEN u.theCol = 'DateJoined'
THEN u.Registrations
ELSE 0
END) AS PeopleJoined ,
SUM(CASE WHEN u.theCol = 'DateLeft'
THEN u.Registrations
ELSE 0
END) AS PeopleLeft
FROM ( SELECT DATEDIFF(MONTH, 0, DateJoined)
AS DateJoined ,
DATEDIFF(MONTH, 0, DateLeft)
AS DateLeft ,
COUNT(*) AS Registrations
FROM dbo.Registrations2
GROUP BY DATEDIFF(MONTH, 0, DateJoined) ,
DATEDIFF(MONTH, 0, DateLeft)
) AS d UNPIVOT ( theMonth FOR theCol
IN ( d.DateJoined,
d.DateLeft ) ) AS u
GROUP BY u.theMonth
HAVING SUM(CASE WHEN u.theCol = 'DateJoined'
THEN u.Registrations
ELSE 0
END) > 0
)
SELECT TheMonth ,
PeopleJoined ,
PeopleLeft ,
SUM(PeopleJoined - PeopleLeft) OVER ( ORDER BY TheMonth
ROWS UNBOUNDED PRECEDING ) AS CurrentSubscribers
FROM Totals;
Classic Running Total Problem
A Registrations table containing a list of
subscribers, with the dates that the subscribers
joined and left
#SQLintheCityUK
WITH Totals
AS ( SELECT DATEADD(m, u.theMonth, 0) AS TheMonth ,
SUM(CASE WHEN u.theCol = 'DateJoined'
THEN u.Registrations
ELSE 0
END) AS PeopleJoined ,
SUM(CASE WHEN u.theCol = 'DateLeft'
THEN u.Registrations
ELSE 0
END) AS PeopleLeft
FROM ( SELECT DATEDIFF(MONTH, 0, DateJoined)
AS DateJoined ,
DATEDIFF(MONTH, 0, DateLeft)
AS DateLeft ,
COUNT(*) AS Registrations
FROM dbo.Registrations2
GROUP BY DATEDIFF(MONTH, 0, DateJoined) ,
DATEDIFF(MONTH, 0, DateLeft)
) AS d UNPIVOT ( theMonth FOR theCol
IN ( d.DateJoined,
d.DateLeft ) ) AS u
GROUP BY u.theMonth
HAVING SUM(CASE WHEN u.theCol = 'DateJoined'
THEN u.Registrations
ELSE 0
END) > 0
)
SELECT TheMonth ,
PeopleJoined ,
PeopleLeft ,
SUM(PeopleJoined - PeopleLeft) OVER ( ORDER BY TheMonth
ROWS UNBOUNDED PRECEDING ) AS CurrentSubscribers
FROM Totals;
A single ‘pass’
of the base table
Early
Aggregation
10000001690
Execution Plan
#SQLintheCityUK
Problem: Excessive logical reads
• “Read 1000 pages to return 100 rows”
– 1 page = 1 logical read
– Goal: return data with few logical reads as possible
– Sometimes we force SQL Server to read more pages than necessary (excessive IO)
Inefficient data access paths (indexes)
Inefficient SQL forcing SQL Server to do
excessive work

#SQLintheCityUK
Name
(Index Key)
A - Z
+ LocationID
Name
(Index Key)
A - E
+ LocationID
Name
(Index Key)
F - I
+ LocationID
Name
(Index Key)
J - M
+ LocationID
Name
(Index Key)
N - R
+ LocationID
Name
(Index Key)
S - V
+ LocationID
Name
(Index Key)
W - Z
+ LocationID
Root Node
Intermediate Level
Leaf Level
Name
(Index Key)
A - M
+ LocationID
Name
(Index Key)
N - Z
+ LocationID
WHERE
l.Name ='Paint';Non-clustered Index
#SQLintheCityUK
Name
(Index Key)
A - Z
+ LocationID
Name
(Index Key)
A - E
+ LocationID
Name
(Index Key)
F - I
+ LocationID
Name
(Index Key)
J - M
+ LocationID
Name
(Index Key)
N - R
+ LocationID
Name
(Index Key)
S - V
+ LocationID
Name
(Index Key)
W - Z
+ LocationID
Root Node
Intermediate Level
Leaf Level
Name
(Index Key)
A - M
+ LocationID
Name
(Index Key)
N - Z
+ LocationID
WHERE
l.Name ='Paint';Non-clustered Index
#SQLintheCityUK
LocationID = 6;
(ProductID,
LocationID)
(Clustering Key)
1 to 12000
(ProductID,
LocationID)
1-6000
(ProductID,
LocationID)
6001-12000
Data rows
for
ProductID
1-2000
Data rows
for
ProductID
2001-4000
Data rows
for
ProductID
4001-6000
Data rows
for
ProductID
6001-8000
Data rows
for
ProductID
80001-10000
Data rows
for
ProductID
10001-12000
Root Node
Intermediate Level
Leaf Level(502,6) (4325,6) (10324,6)(7865,6)
Clustered Index
#SQLintheCityUK
LocationID = 6;
(ProductID,
LocationID)
(Clustering Key)
1 to 12000
(ProductID,
LocationID)
1-6000
(ProductID,
LocationID)
6001-12000
Data rows
for
ProductID
1-2000
Data rows
for
ProductID
2001-4000
Data rows
for
ProductID
4001-6000
Data rows
for
ProductID
6001-8000
Data rows
for
ProductID
80001-10000
Data rows
for
ProductID
10001-12000
Root Node
Intermediate Level
Leaf Level
Clustered Index
#SQLintheCityUK
LocationID = 6;
(ProductID,
LocationID)
(Clustering Key)
1 to 12000
(ProductID,
LocationID)
1-6000
(ProductID,
LocationID)
6001-12000
Data rows
for
ProductID
1-2000
Data rows
for
ProductID
2001-4000
Data rows
for
ProductID
4001-6000
Data rows
for
ProductID
6001-8000
Data rows
for
ProductID
80001-10000
Data rows
for
ProductID
10001-12000
Root Node
Intermediate Level
Leaf Level
#SQLintheCityUK
#SQLintheCityUK
ProductID
(Index Key)
A - Z
+ SalesOrderID
ProductID
(Index Key)
1 - 150
+ SalesOrderID
ProductID
(Index Key)
151 - 300
+ SalesOrderID
ProductID
(Index Key)
301 - 450
+ SalesOrderID
ProductID
(Index Key)
451 - 600
+ SalesOrderID
ProductID
(Index Key)
601 - 750
+ SalesOrderID
ProductID
(Index Key)
751 - 900
+ SalesOrderID
Root Node
Intermediate Level
Leaf Level
ProductID
(Index Key)
A - M
+ SalesOrderID
ProductID
(Index Key)
N - Z
+ SalesOrderID
Lookup
CarrierTrackingNumber
in clustered index
for each row
Key Lookup
SELECT ProductID ,
SalesOrderID ,
CarrierTrackingNumber
FROM Sales.SalesOrderDetail
WHERE ProductID = 709;
#SQLintheCityUK
#SQLintheCityUK
#SQLintheCityUK
• For small tables, scanning an index is very
efficient operation
• BUT…for critical and frequently-executed
queries:
– Provide covering non-clustered indexes that the
queries can seek
– Minimize logical reads (IO) required to gather the
data
Solution: optimize indexes for workloadSolution: optimize indexes for workload
#SQLintheCityUK
–Worst Strategy: No indexes.
Query performance will be terrible
–Second worst: Index on every column; same
column participating in numerous indexes
Data modification performance will be awful
–Don’t do “SELECT *”
Makes effective indexing VERY hard!
Solution: optimize indexes for workloadSolution: optimize indexes for workload
#SQLintheCityUK
• Don’t index query by query
• Goal: small set of indexes to help most important and frequent queries
• Analyze the workload as a whole
– Profiler and Database Engine Tuning Advisor
• Good start point…
• Not necessarily good end point
– Refine recommendations using Missing Index (and other) DMVs
• What is the write : read ratio (>1?) for the index?
• How many plans currently associated with index?
• How often are those plans used?
• How many reads might the missing index have helped? Don’t create if this number is small…
– See Performance Tuning with SQL Server Dynamic Management Views (free eBook)
• http://bit.ly/1jVG3IW
Solution: optimize indexes for workload
“The explicit data type conversion
has rendered the predicate non-SARGable!”
Problem: Non-SARGable Predicates
#SQLintheCityUK
Beware of SARG-ability
• Non-SARGable means that the optimizer can’t
use the expression in a seek operation
• Cause: use of function directly on column in
WHERE or JOIN
– Various incarnations
– All lead to excessive IO (scans when seeks should be viable)
#SQLintheCityUK
SARG-able predicate
…WHERE FirstName = 'bob';  SARGable
FirstName LastName
Aaron Bertrand
Aaron Darrenovsky
Amber Smith
Apple Paltrow
Bob Duffy
Bob Carolgees
Chris Christofferson
…etc...
#SQLintheCityUK
Non SARGable predicate
…WHERE REVERSE(FirstName) = 'bob';
FirstName LastName
Aaron Bertrand
Aaron Darrenovsky
Amber Smith
Apple Paltrow
Bob Duffy
Bob Carolgees
Chris Christofferson
…etc...
REVERSE ('Aaron') = 'bob' ?
#SQLintheCityUK
Non SARG-able predicate
…WHERE REVERSE(FirstName) = 'bob';
FirstName LastName
Aaron Bertrand
Aaron Darrenovsky
Amber Smith
Apple Paltrow
Bob Duffy
Bob Carolgees
Chris Christofferson
…etc...
REVERSE ('Aaron') = 'bob' ?
#SQLintheCityUK
Non SARGable predicate
…WHERE REVERSE(FirstName) = 'bob';
FirstName LastName
Aaron Bertrand
Aaron Darrenovsky
Amber Smith
Apple Paltrow
Bob Duffy
Bob Carolgees
Chris Christofferson
…etc...
REVERSE ('Amber') = 'bob' ?
 Non-SARGable
#SQLintheCityUK
#SQLintheCityUK
Other common explicit conversions
-- Using functions like LTRIM, RTRIM etc.
-- often happens where people don't trust
consistency of data inputs
SELECT bp.ProductID ,
bp.Name ,
bp.ProductNumber
FROM dbo.bigProduct bp
WHERE LTRIM(bp.ProductNumber) LIKE 'AR%';
GO
SELECT bp.ProductID ,
bp.Name ,
bp.ProductNumber
FROM dbo.bigProduct bp
WHERE bp.ProductNumber LIKE N'%1000';
GO
#SQLintheCityUK
Other causes of Non-SARG
• Implicit Data type conversions
– Variable data type doesn’t match column type
– SQL Server uses CONVERT_IMPLICIT
– Problem if column is lower precedence type
• Data type precedence order: http://bit.ly/1ENOwjZ
• Misuse of User Defined Functions (UDFs)
#SQLintheCityUK
• Rewrite the query to avoid direct use of
function on column
• Use helper functions
• Avoid data type mismatches
• Be careful when using UDFs!
– Convert scalar UDFs to inline TVFs
– http://bit.ly/1oN9ysK
Solutions to Non-SARGability
#SQLintheCityUK
• One query size fits all
• Leads to wildly inaccurate estimations and
inappropriate execution plans
Problem: Overly Generic SQL
#SQLintheCityUK
#SQLintheCityUK
• Write SQL and stored procedures for a specific, defined
purpose
• Various ‘workarounds’ though none without drawbacks
– Recompile on each execution
– Dynamic SQL
– See Gail Shaw’s “How to Confuse the Query Optimizer”
(http://bit.ly/1Mb8Rnp)
Solutions to Generic SQL
#SQLintheCityUK
Other issues that cause
poor estimations
• Stale statistics
• Problems with parameter sniffing
#SQLintheCityUK
Very wild estimation!
#SQLintheCityUK
Conclusions
• Plans tell us exactly how SQL Server executed your
query
– Focus on critical and frequently-executed queries
– Use plans to:
• spot common mistakes in the code
• Uncover problems with inefficient indexing
– Work with rather than against SQL Server
#SQLintheCityUK
Thank you to…
• Grant Fritchey - @GFritchey
• Hugo Kornelis - @Hugo_Kornelis
• Gail Shaw - @SQLintheWild
• Rodney Landrum - @SQLBeat
• Phil Factor - @Phil_Factor
#SQLintheCityUK

Contenu connexe

Tendances

Sql server performance tuning and optimization
Sql server performance tuning and optimizationSql server performance tuning and optimization
Sql server performance tuning and optimizationManish Rawat
 
Before you optimize: Understanding Execution Plans
Before you optimize: Understanding Execution PlansBefore you optimize: Understanding Execution Plans
Before you optimize: Understanding Execution PlansTimothy Corey
 
Sql server performance tuning
Sql server performance tuningSql server performance tuning
Sql server performance tuningngupt28
 
Database Performance Tuning
Database Performance Tuning Database Performance Tuning
Database Performance Tuning Arno Huetter
 
Sql Server Performance Tuning
Sql Server Performance TuningSql Server Performance Tuning
Sql Server Performance TuningBala Subra
 
Top 10 tips for Oracle performance (Updated April 2015)
Top 10 tips for Oracle performance (Updated April 2015)Top 10 tips for Oracle performance (Updated April 2015)
Top 10 tips for Oracle performance (Updated April 2015)Guy Harrison
 
SQL Server Optimization Checklist
SQL Server Optimization ChecklistSQL Server Optimization Checklist
SQL Server Optimization ChecklistGrant Fritchey
 
Stored procedure tuning and optimization t sql
Stored procedure tuning and optimization t sqlStored procedure tuning and optimization t sql
Stored procedure tuning and optimization t sqlnishantdavid9
 
Sql server performance tuning
Sql server performance tuningSql server performance tuning
Sql server performance tuningJugal Shah
 
Oracle performance tuning_sfsf
Oracle performance tuning_sfsfOracle performance tuning_sfsf
Oracle performance tuning_sfsfMao Geng
 
The Plan Cache Whisperer - Performance Tuning SQL Server
The Plan Cache Whisperer - Performance Tuning SQL ServerThe Plan Cache Whisperer - Performance Tuning SQL Server
The Plan Cache Whisperer - Performance Tuning SQL ServerJason Strate
 
Advanced integration services on microsoft ssis 1
Advanced integration services on microsoft ssis 1Advanced integration services on microsoft ssis 1
Advanced integration services on microsoft ssis 1Skillwise Group
 
Oracle Performance Tuning Training | Oracle Performance Tuning
Oracle Performance Tuning Training | Oracle Performance TuningOracle Performance Tuning Training | Oracle Performance Tuning
Oracle Performance Tuning Training | Oracle Performance TuningOracleTrainings
 
Oracle Database Performance Tuning Basics
Oracle Database Performance Tuning BasicsOracle Database Performance Tuning Basics
Oracle Database Performance Tuning Basicsnitin anjankar
 
Proactive performance monitoring with adaptive thresholds
Proactive performance monitoring with adaptive thresholdsProactive performance monitoring with adaptive thresholds
Proactive performance monitoring with adaptive thresholdsJohn Beresniewicz
 
SQL Server Performance Tuning Baseline
SQL Server Performance Tuning BaselineSQL Server Performance Tuning Baseline
SQL Server Performance Tuning Baseline► Supreme Mandal ◄
 
Oracle db performance tuning
Oracle db performance tuningOracle db performance tuning
Oracle db performance tuningSimon Huang
 

Tendances (20)

Sql server performance tuning and optimization
Sql server performance tuning and optimizationSql server performance tuning and optimization
Sql server performance tuning and optimization
 
Before you optimize: Understanding Execution Plans
Before you optimize: Understanding Execution PlansBefore you optimize: Understanding Execution Plans
Before you optimize: Understanding Execution Plans
 
Sql server performance tuning
Sql server performance tuningSql server performance tuning
Sql server performance tuning
 
Database Performance Tuning
Database Performance Tuning Database Performance Tuning
Database Performance Tuning
 
Sql Server Performance Tuning
Sql Server Performance TuningSql Server Performance Tuning
Sql Server Performance Tuning
 
Top 10 tips for Oracle performance (Updated April 2015)
Top 10 tips for Oracle performance (Updated April 2015)Top 10 tips for Oracle performance (Updated April 2015)
Top 10 tips for Oracle performance (Updated April 2015)
 
SQL Server Optimization Checklist
SQL Server Optimization ChecklistSQL Server Optimization Checklist
SQL Server Optimization Checklist
 
Stored procedure tuning and optimization t sql
Stored procedure tuning and optimization t sqlStored procedure tuning and optimization t sql
Stored procedure tuning and optimization t sql
 
Sql server performance tuning
Sql server performance tuningSql server performance tuning
Sql server performance tuning
 
Oracle performance tuning_sfsf
Oracle performance tuning_sfsfOracle performance tuning_sfsf
Oracle performance tuning_sfsf
 
The Plan Cache Whisperer - Performance Tuning SQL Server
The Plan Cache Whisperer - Performance Tuning SQL ServerThe Plan Cache Whisperer - Performance Tuning SQL Server
The Plan Cache Whisperer - Performance Tuning SQL Server
 
Database Testing
Database TestingDatabase Testing
Database Testing
 
Advanced integration services on microsoft ssis 1
Advanced integration services on microsoft ssis 1Advanced integration services on microsoft ssis 1
Advanced integration services on microsoft ssis 1
 
Oracle Performance Tuning Training | Oracle Performance Tuning
Oracle Performance Tuning Training | Oracle Performance TuningOracle Performance Tuning Training | Oracle Performance Tuning
Oracle Performance Tuning Training | Oracle Performance Tuning
 
Oracle Database Performance Tuning Basics
Oracle Database Performance Tuning BasicsOracle Database Performance Tuning Basics
Oracle Database Performance Tuning Basics
 
Unit Testing SQL Server
Unit Testing SQL ServerUnit Testing SQL Server
Unit Testing SQL Server
 
Oracle SQL Tuning
Oracle SQL TuningOracle SQL Tuning
Oracle SQL Tuning
 
Proactive performance monitoring with adaptive thresholds
Proactive performance monitoring with adaptive thresholdsProactive performance monitoring with adaptive thresholds
Proactive performance monitoring with adaptive thresholds
 
SQL Server Performance Tuning Baseline
SQL Server Performance Tuning BaselineSQL Server Performance Tuning Baseline
SQL Server Performance Tuning Baseline
 
Oracle db performance tuning
Oracle db performance tuningOracle db performance tuning
Oracle db performance tuning
 

Similaire à Uncovering SQL Server query problems with execution plans - Tony Davis

Chris Seebacher Portfolio
Chris Seebacher PortfolioChris Seebacher Portfolio
Chris Seebacher Portfolioguest3ea163
 
Kevin Bengtson Portfolio
Kevin Bengtson PortfolioKevin Bengtson Portfolio
Kevin Bengtson PortfolioKbengt521
 
When to NoSQL and when to know SQL
When to NoSQL and when to know SQLWhen to NoSQL and when to know SQL
When to NoSQL and when to know SQLSimon Elliston Ball
 
Relational Database to Apache Spark (and sometimes back again)
Relational Database to Apache Spark (and sometimes back again)Relational Database to Apache Spark (and sometimes back again)
Relational Database to Apache Spark (and sometimes back again)Ed Thewlis
 
Business Intelligence Portfolio
Business Intelligence PortfolioBusiness Intelligence Portfolio
Business Intelligence PortfolioChris Seebacher
 
Social media analytics using Azure Technologies
Social media analytics using Azure TechnologiesSocial media analytics using Azure Technologies
Social media analytics using Azure TechnologiesKoray Kocabas
 
Lucian Precup - Back to the Future: SQL 92 for Elasticsearch? - NoSQL matters...
Lucian Precup - Back to the Future: SQL 92 for Elasticsearch? - NoSQL matters...Lucian Precup - Back to the Future: SQL 92 for Elasticsearch? - NoSQL matters...
Lucian Precup - Back to the Future: SQL 92 for Elasticsearch? - NoSQL matters...NoSQLmatters
 
Real Time Analytics with Apache Cassandra - Cassandra Day Munich
Real Time Analytics with Apache Cassandra - Cassandra Day MunichReal Time Analytics with Apache Cassandra - Cassandra Day Munich
Real Time Analytics with Apache Cassandra - Cassandra Day MunichGuido Schmutz
 
U-SQL Query Execution and Performance Tuning
U-SQL Query Execution and Performance TuningU-SQL Query Execution and Performance Tuning
U-SQL Query Execution and Performance TuningMichael Rys
 
Moving from SQL Server to MongoDB
Moving from SQL Server to MongoDBMoving from SQL Server to MongoDB
Moving from SQL Server to MongoDBNick Court
 
SQL Server 2008 Portfolio
SQL Server 2008 PortfolioSQL Server 2008 Portfolio
SQL Server 2008 Portfoliolilredlokita
 
SQLBits Module 2 RStats Introduction to R and Statistics
SQLBits Module 2 RStats Introduction to R and StatisticsSQLBits Module 2 RStats Introduction to R and Statistics
SQLBits Module 2 RStats Introduction to R and StatisticsJen Stirrup
 
Data stax webinar cassandra and titandb insights into datastax graph strategy...
Data stax webinar cassandra and titandb insights into datastax graph strategy...Data stax webinar cassandra and titandb insights into datastax graph strategy...
Data stax webinar cassandra and titandb insights into datastax graph strategy...DataStax
 
CMS Project Phase II InstructionsIn this phase, you will create t.docx
CMS Project Phase II InstructionsIn this phase, you will create t.docxCMS Project Phase II InstructionsIn this phase, you will create t.docx
CMS Project Phase II InstructionsIn this phase, you will create t.docxmary772
 
Greg Lewis SQL Portfolio
Greg Lewis SQL PortfolioGreg Lewis SQL Portfolio
Greg Lewis SQL Portfoliogregmlewis
 
Back to the future : SQL 92 for Elasticsearch @nosqlmatters Paris
Back to the future : SQL 92 for Elasticsearch @nosqlmatters ParisBack to the future : SQL 92 for Elasticsearch @nosqlmatters Paris
Back to the future : SQL 92 for Elasticsearch @nosqlmatters ParisLucian Precup
 

Similaire à Uncovering SQL Server query problems with execution plans - Tony Davis (20)

Do You Have the Time
Do You Have the TimeDo You Have the Time
Do You Have the Time
 
Chris Seebacher Portfolio
Chris Seebacher PortfolioChris Seebacher Portfolio
Chris Seebacher Portfolio
 
Kevin Bengtson Portfolio
Kevin Bengtson PortfolioKevin Bengtson Portfolio
Kevin Bengtson Portfolio
 
When to NoSQL and when to know SQL
When to NoSQL and when to know SQLWhen to NoSQL and when to know SQL
When to NoSQL and when to know SQL
 
Relational Database to Apache Spark (and sometimes back again)
Relational Database to Apache Spark (and sometimes back again)Relational Database to Apache Spark (and sometimes back again)
Relational Database to Apache Spark (and sometimes back again)
 
My Portfolio
My PortfolioMy Portfolio
My Portfolio
 
My Portfolio
My PortfolioMy Portfolio
My Portfolio
 
Business Intelligence Portfolio
Business Intelligence PortfolioBusiness Intelligence Portfolio
Business Intelligence Portfolio
 
Social media analytics using Azure Technologies
Social media analytics using Azure TechnologiesSocial media analytics using Azure Technologies
Social media analytics using Azure Technologies
 
Lucian Precup - Back to the Future: SQL 92 for Elasticsearch? - NoSQL matters...
Lucian Precup - Back to the Future: SQL 92 for Elasticsearch? - NoSQL matters...Lucian Precup - Back to the Future: SQL 92 for Elasticsearch? - NoSQL matters...
Lucian Precup - Back to the Future: SQL 92 for Elasticsearch? - NoSQL matters...
 
Real Time Analytics with Apache Cassandra - Cassandra Day Munich
Real Time Analytics with Apache Cassandra - Cassandra Day MunichReal Time Analytics with Apache Cassandra - Cassandra Day Munich
Real Time Analytics with Apache Cassandra - Cassandra Day Munich
 
U-SQL Query Execution and Performance Tuning
U-SQL Query Execution and Performance TuningU-SQL Query Execution and Performance Tuning
U-SQL Query Execution and Performance Tuning
 
Moving from SQL Server to MongoDB
Moving from SQL Server to MongoDBMoving from SQL Server to MongoDB
Moving from SQL Server to MongoDB
 
SQL Server 2008 Portfolio
SQL Server 2008 PortfolioSQL Server 2008 Portfolio
SQL Server 2008 Portfolio
 
SQLBits Module 2 RStats Introduction to R and Statistics
SQLBits Module 2 RStats Introduction to R and StatisticsSQLBits Module 2 RStats Introduction to R and Statistics
SQLBits Module 2 RStats Introduction to R and Statistics
 
Data stax webinar cassandra and titandb insights into datastax graph strategy...
Data stax webinar cassandra and titandb insights into datastax graph strategy...Data stax webinar cassandra and titandb insights into datastax graph strategy...
Data stax webinar cassandra and titandb insights into datastax graph strategy...
 
CMS Project Phase II InstructionsIn this phase, you will create t.docx
CMS Project Phase II InstructionsIn this phase, you will create t.docxCMS Project Phase II InstructionsIn this phase, you will create t.docx
CMS Project Phase II InstructionsIn this phase, you will create t.docx
 
Greg Lewis SQL Portfolio
Greg Lewis SQL PortfolioGreg Lewis SQL Portfolio
Greg Lewis SQL Portfolio
 
Back to the future : SQL 92 for Elasticsearch @nosqlmatters Paris
Back to the future : SQL 92 for Elasticsearch @nosqlmatters ParisBack to the future : SQL 92 for Elasticsearch @nosqlmatters Paris
Back to the future : SQL 92 for Elasticsearch @nosqlmatters Paris
 
SQL Windowing
SQL WindowingSQL Windowing
SQL Windowing
 

Plus de Red Gate Software

The future of DevOps: fully left-shifted deployments with version control and...
The future of DevOps: fully left-shifted deployments with version control and...The future of DevOps: fully left-shifted deployments with version control and...
The future of DevOps: fully left-shifted deployments with version control and...Red Gate Software
 
Embracing DevOps through database migrations with Flyway
Embracing DevOps through database migrations with FlywayEmbracing DevOps through database migrations with Flyway
Embracing DevOps through database migrations with FlywayRed Gate Software
 
Database DevOps for Managed Service Providers
Database DevOps for Managed Service ProvidersDatabase DevOps for Managed Service Providers
Database DevOps for Managed Service ProvidersRed Gate Software
 
Mizuho Financial: Launching our Database DevOps journey
Mizuho Financial: Launching our Database DevOps journeyMizuho Financial: Launching our Database DevOps journey
Mizuho Financial: Launching our Database DevOps journeyRed Gate Software
 
7 steps to effective SQL Server monitoring
7 steps to effective SQL Server monitoring7 steps to effective SQL Server monitoring
7 steps to effective SQL Server monitoringRed Gate Software
 
Level up your deployments for SQL Source Control
Level up your deployments for SQL Source Control Level up your deployments for SQL Source Control
Level up your deployments for SQL Source Control Red Gate Software
 
Key findings from the 2020 state of database dev ops report
Key findings from the 2020 state of database dev ops reportKey findings from the 2020 state of database dev ops report
Key findings from the 2020 state of database dev ops reportRed Gate Software
 
Extend DevOps to Your SQL Server Databases
Extend DevOps to Your SQL Server DatabasesExtend DevOps to Your SQL Server Databases
Extend DevOps to Your SQL Server DatabasesRed Gate Software
 
What we learned at PASS Summit in 2019
What we learned at PASS Summit in 2019What we learned at PASS Summit in 2019
What we learned at PASS Summit in 2019Red Gate Software
 
Quality in Software Development: Anglia Ruskin University
Quality in Software Development: Anglia Ruskin UniversityQuality in Software Development: Anglia Ruskin University
Quality in Software Development: Anglia Ruskin UniversityRed Gate Software
 
How SQL Change Automation helps you deliver value faster
How SQL Change Automation helps you deliver value fasterHow SQL Change Automation helps you deliver value faster
How SQL Change Automation helps you deliver value fasterRed Gate Software
 
DevOps essentials from Abel Wang and Steve Jones
DevOps essentials from Abel Wang and Steve JonesDevOps essentials from Abel Wang and Steve Jones
DevOps essentials from Abel Wang and Steve JonesRed Gate Software
 
Successfully migrating existing databases to Azure
Successfully migrating existing databases to AzureSuccessfully migrating existing databases to Azure
Successfully migrating existing databases to AzureRed Gate Software
 
The Ultimate Guide to Choosing and Implementing the Right Monitoring Tool
The Ultimate Guide to Choosing and Implementing the Right Monitoring ToolThe Ultimate Guide to Choosing and Implementing the Right Monitoring Tool
The Ultimate Guide to Choosing and Implementing the Right Monitoring ToolRed Gate Software
 
Everything You Need to Know About the 2019 DORA Accelerate State of DevOps Re...
Everything You Need to Know About the 2019 DORA Accelerate State of DevOps Re...Everything You Need to Know About the 2019 DORA Accelerate State of DevOps Re...
Everything You Need to Know About the 2019 DORA Accelerate State of DevOps Re...Red Gate Software
 
Using Redgate, AKS and Azure to bring DevOps to your database
Using Redgate, AKS and Azure to bring DevOps to your databaseUsing Redgate, AKS and Azure to bring DevOps to your database
Using Redgate, AKS and Azure to bring DevOps to your databaseRed Gate Software
 
Using Redgate, AKS and Azure to bring DevOps to your Database
Using Redgate, AKS and Azure to bring DevOps to your DatabaseUsing Redgate, AKS and Azure to bring DevOps to your Database
Using Redgate, AKS and Azure to bring DevOps to your DatabaseRed Gate Software
 
How to Pitch a Software Development Initiative and Ignite Culture Change
How to Pitch a Software Development Initiative and Ignite Culture ChangeHow to Pitch a Software Development Initiative and Ignite Culture Change
How to Pitch a Software Development Initiative and Ignite Culture ChangeRed Gate Software
 

Plus de Red Gate Software (20)

The future of DevOps: fully left-shifted deployments with version control and...
The future of DevOps: fully left-shifted deployments with version control and...The future of DevOps: fully left-shifted deployments with version control and...
The future of DevOps: fully left-shifted deployments with version control and...
 
Embracing DevOps through database migrations with Flyway
Embracing DevOps through database migrations with FlywayEmbracing DevOps through database migrations with Flyway
Embracing DevOps through database migrations with Flyway
 
Database DevOps for Managed Service Providers
Database DevOps for Managed Service ProvidersDatabase DevOps for Managed Service Providers
Database DevOps for Managed Service Providers
 
Mizuho Financial: Launching our Database DevOps journey
Mizuho Financial: Launching our Database DevOps journeyMizuho Financial: Launching our Database DevOps journey
Mizuho Financial: Launching our Database DevOps journey
 
7 steps to effective SQL Server monitoring
7 steps to effective SQL Server monitoring7 steps to effective SQL Server monitoring
7 steps to effective SQL Server monitoring
 
Level up your deployments for SQL Source Control
Level up your deployments for SQL Source Control Level up your deployments for SQL Source Control
Level up your deployments for SQL Source Control
 
Key findings from the 2020 state of database dev ops report
Key findings from the 2020 state of database dev ops reportKey findings from the 2020 state of database dev ops report
Key findings from the 2020 state of database dev ops report
 
Extend DevOps to Your SQL Server Databases
Extend DevOps to Your SQL Server DatabasesExtend DevOps to Your SQL Server Databases
Extend DevOps to Your SQL Server Databases
 
2019 year in review slides
2019 year in review slides2019 year in review slides
2019 year in review slides
 
What we learned at PASS Summit in 2019
What we learned at PASS Summit in 2019What we learned at PASS Summit in 2019
What we learned at PASS Summit in 2019
 
Quality in Software Development: Anglia Ruskin University
Quality in Software Development: Anglia Ruskin UniversityQuality in Software Development: Anglia Ruskin University
Quality in Software Development: Anglia Ruskin University
 
How SQL Change Automation helps you deliver value faster
How SQL Change Automation helps you deliver value fasterHow SQL Change Automation helps you deliver value faster
How SQL Change Automation helps you deliver value faster
 
DevOps essentials from Abel Wang and Steve Jones
DevOps essentials from Abel Wang and Steve JonesDevOps essentials from Abel Wang and Steve Jones
DevOps essentials from Abel Wang and Steve Jones
 
Successfully migrating existing databases to Azure
Successfully migrating existing databases to AzureSuccessfully migrating existing databases to Azure
Successfully migrating existing databases to Azure
 
The Ultimate Guide to Choosing and Implementing the Right Monitoring Tool
The Ultimate Guide to Choosing and Implementing the Right Monitoring ToolThe Ultimate Guide to Choosing and Implementing the Right Monitoring Tool
The Ultimate Guide to Choosing and Implementing the Right Monitoring Tool
 
Everything You Need to Know About the 2019 DORA Accelerate State of DevOps Re...
Everything You Need to Know About the 2019 DORA Accelerate State of DevOps Re...Everything You Need to Know About the 2019 DORA Accelerate State of DevOps Re...
Everything You Need to Know About the 2019 DORA Accelerate State of DevOps Re...
 
Using Redgate, AKS and Azure to bring DevOps to your database
Using Redgate, AKS and Azure to bring DevOps to your databaseUsing Redgate, AKS and Azure to bring DevOps to your database
Using Redgate, AKS and Azure to bring DevOps to your database
 
Using Redgate, AKS and Azure to bring DevOps to your Database
Using Redgate, AKS and Azure to bring DevOps to your DatabaseUsing Redgate, AKS and Azure to bring DevOps to your Database
Using Redgate, AKS and Azure to bring DevOps to your Database
 
How to Pitch a Software Development Initiative and Ignite Culture Change
How to Pitch a Software Development Initiative and Ignite Culture ChangeHow to Pitch a Software Development Initiative and Ignite Culture Change
How to Pitch a Software Development Initiative and Ignite Culture Change
 
Taming the Wild West
Taming the Wild West Taming the Wild West
Taming the Wild West
 

Dernier

why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 

Dernier (20)

why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 

Uncovering SQL Server query problems with execution plans - Tony Davis

  • 1. Uncovering SQL Server Query Problems with Execution Plans Tony Davis tony.davis@red-gate.com @tonytheeditor #SQLintheCityUK
  • 2. About Me Books SQL Server transaction log SQL Server Source Control Speaker #SQLintheCityUK
  • 3. SELECT ProductID , ProductNumber , dbo.LineItemTotal(ProductID) AS SumTotal FROM Production.Product p GO SELECT bth.ProductID , bth.TransactionDate , bth.Quantity , bth.ActualCost FROM dbo.bigTransactionHistory bth WHERE bth.TransactionDate >= '20100701' AND bth.TransactionDate <= CURRENT_TIMESTAMP ORDER BY bth.TransactionDate DESC; GO Why Bother Learning Execution Plans? WITH Totals AS ( SELECT DATEADD(m, u.theMonth, 0) AS TheMonth , SUM(CASE WHEN u.theCol = 'DateJoined' THEN u.Registrations ELSE 0 END) AS PeopleJoined , SUM(CASE WHEN u.theCol = 'DateLeft' THEN u.Registrations ELSE 0 END) AS PeopleLeft FROM ( SELECT DATEDIFF(MONTH, 0, DateJoined) AS DateJoined , DATEDIFF(MONTH, 0, DateLeft) AS DateLeft , COUNT(*) AS Registrations FROM dbo.Registrations2 GROUP BY DATEDIFF(MONTH, 0, DateJoined) , DATEDIFF(MONTH, 0, DateLeft) ) AS d UNPIVOT ( theMonth FOR theCol IN ( d.DateJoined, d.DateLeft ) ) AS u GROUP BY u.theMonth HAVING SUM(CASE WHEN u.theCol = 'DateJoined' THEN u.Registrations ELSE 0 END) > 0 ) SELECT TheMonth , PeopleJoined , PeopleLeft , SUM(PeopleJoined - PeopleLeft) OVER ( ORDER BY TheMonth ROWS UNBOUNDED PRECEDING ) AS CurrentSubscribers FROM Totals;
  • 4. From Query to Execution plan SELECT bth.ProductID , bth.TransactionDate , bth.Quantity , bth.ActualCost FROM dbo.bigTransactionHistory bth WHERE bth.TransactionDate >= '20100701' AND bth.TransactionDate <= CURRENT_TIMESTAMP ORDER BY bth.TransactionDate DESC; GO #SQLintheCityUK
  • 5. Plan 1 Plan 2 Plan 3 Plan 4 Plan 57 Plan n? Algebrizer (Query Binding) Syntax Checking (Query Parsing) Query Optimization Plan Query Execution Engine Plan Cache Metadata Table/index structures SELECT bth.ProductID , bth.TransactionDate , bth.Quantity , bth.ActualCost FROM dbo.bigTransactionHistory bth WHERE bth.TransactionDate >= '20100701' AND bth.TransactionDate <= CURRENT_TIMESTAMP ORDER BY bth.TransactionDate DESC; GO Index/Column Statistics Volume/distribution of data #SQLintheCityUK
  • 6. Getting the Execution Plan .NET Code Profiler - e.g. ANTS Performance Profiler Get plans for previously executed queries from the plan cache - e.g. SQL Trace or Extended Events - Using sys.dm_exec_cached_plans Plans in cache contain no runtime information  #SQLintheCityUK
  • 8. Getting the Execution Plan .NET Code Profiler - e.g. ANTS Performance Profiler Get plans for previously executed queries from the plan cache - e.g. SQL Trace or Extended Events - Using sys.dm_exec_cached_plans Plans in cache contain no runtime information  SET During testing, request the plan for a query • “estimated” plan – no runtime • “actual” plan - with runtime There is only 1 plan!  #SQLintheCityUK
  • 10. Execution Plans for Developers • Don’t examine plan for every query • Gather stats, focus on critical, frequent, resource- intensive queries • Sometimes the code logic is just wrong – rip it up and start again! • Sometimes the basic logic is fine – But some subtler problem causes poor execution performance – This is where execution plans can help! #SQLintheCityUK
  • 11. • With SQL Server: • We submit SQL describing the data set we want • The Optimizer decides how to execute it • Some developers bring imperative approach line- by-line control to SQL Server… Problem: Row-by-row strategy #SQLintheCityUK
  • 32. Solution: set-based approach – Take the list to the supermarket ;) – Define single statement (if possible) to return required data set • Make as few ‘passes’ through the base tables as possible • Aggregate early • Reduce the working set to as few rows as possible #SQLintheCityUK
  • 33. WITH Totals AS ( SELECT DATEADD(m, u.theMonth, 0) AS TheMonth , SUM(CASE WHEN u.theCol = 'DateJoined' THEN u.Registrations ELSE 0 END) AS PeopleJoined , SUM(CASE WHEN u.theCol = 'DateLeft' THEN u.Registrations ELSE 0 END) AS PeopleLeft FROM ( SELECT DATEDIFF(MONTH, 0, DateJoined) AS DateJoined , DATEDIFF(MONTH, 0, DateLeft) AS DateLeft , COUNT(*) AS Registrations FROM dbo.Registrations2 GROUP BY DATEDIFF(MONTH, 0, DateJoined) , DATEDIFF(MONTH, 0, DateLeft) ) AS d UNPIVOT ( theMonth FOR theCol IN ( d.DateJoined, d.DateLeft ) ) AS u GROUP BY u.theMonth HAVING SUM(CASE WHEN u.theCol = 'DateJoined' THEN u.Registrations ELSE 0 END) > 0 ) SELECT TheMonth , PeopleJoined , PeopleLeft , SUM(PeopleJoined - PeopleLeft) OVER ( ORDER BY TheMonth ROWS UNBOUNDED PRECEDING ) AS CurrentSubscribers FROM Totals; Classic Running Total Problem A Registrations table containing a list of subscribers, with the dates that the subscribers joined and left #SQLintheCityUK
  • 34. WITH Totals AS ( SELECT DATEADD(m, u.theMonth, 0) AS TheMonth , SUM(CASE WHEN u.theCol = 'DateJoined' THEN u.Registrations ELSE 0 END) AS PeopleJoined , SUM(CASE WHEN u.theCol = 'DateLeft' THEN u.Registrations ELSE 0 END) AS PeopleLeft FROM ( SELECT DATEDIFF(MONTH, 0, DateJoined) AS DateJoined , DATEDIFF(MONTH, 0, DateLeft) AS DateLeft , COUNT(*) AS Registrations FROM dbo.Registrations2 GROUP BY DATEDIFF(MONTH, 0, DateJoined) , DATEDIFF(MONTH, 0, DateLeft) ) AS d UNPIVOT ( theMonth FOR theCol IN ( d.DateJoined, d.DateLeft ) ) AS u GROUP BY u.theMonth HAVING SUM(CASE WHEN u.theCol = 'DateJoined' THEN u.Registrations ELSE 0 END) > 0 ) SELECT TheMonth , PeopleJoined , PeopleLeft , SUM(PeopleJoined - PeopleLeft) OVER ( ORDER BY TheMonth ROWS UNBOUNDED PRECEDING ) AS CurrentSubscribers FROM Totals; A single ‘pass’ of the base table Early Aggregation 10000001690 Execution Plan #SQLintheCityUK
  • 35. Problem: Excessive logical reads • “Read 1000 pages to return 100 rows” – 1 page = 1 logical read – Goal: return data with few logical reads as possible – Sometimes we force SQL Server to read more pages than necessary (excessive IO) Inefficient data access paths (indexes) Inefficient SQL forcing SQL Server to do excessive work  #SQLintheCityUK
  • 36. Name (Index Key) A - Z + LocationID Name (Index Key) A - E + LocationID Name (Index Key) F - I + LocationID Name (Index Key) J - M + LocationID Name (Index Key) N - R + LocationID Name (Index Key) S - V + LocationID Name (Index Key) W - Z + LocationID Root Node Intermediate Level Leaf Level Name (Index Key) A - M + LocationID Name (Index Key) N - Z + LocationID WHERE l.Name ='Paint';Non-clustered Index #SQLintheCityUK
  • 37. Name (Index Key) A - Z + LocationID Name (Index Key) A - E + LocationID Name (Index Key) F - I + LocationID Name (Index Key) J - M + LocationID Name (Index Key) N - R + LocationID Name (Index Key) S - V + LocationID Name (Index Key) W - Z + LocationID Root Node Intermediate Level Leaf Level Name (Index Key) A - M + LocationID Name (Index Key) N - Z + LocationID WHERE l.Name ='Paint';Non-clustered Index #SQLintheCityUK
  • 38. LocationID = 6; (ProductID, LocationID) (Clustering Key) 1 to 12000 (ProductID, LocationID) 1-6000 (ProductID, LocationID) 6001-12000 Data rows for ProductID 1-2000 Data rows for ProductID 2001-4000 Data rows for ProductID 4001-6000 Data rows for ProductID 6001-8000 Data rows for ProductID 80001-10000 Data rows for ProductID 10001-12000 Root Node Intermediate Level Leaf Level(502,6) (4325,6) (10324,6)(7865,6) Clustered Index #SQLintheCityUK
  • 39. LocationID = 6; (ProductID, LocationID) (Clustering Key) 1 to 12000 (ProductID, LocationID) 1-6000 (ProductID, LocationID) 6001-12000 Data rows for ProductID 1-2000 Data rows for ProductID 2001-4000 Data rows for ProductID 4001-6000 Data rows for ProductID 6001-8000 Data rows for ProductID 80001-10000 Data rows for ProductID 10001-12000 Root Node Intermediate Level Leaf Level Clustered Index #SQLintheCityUK
  • 40. LocationID = 6; (ProductID, LocationID) (Clustering Key) 1 to 12000 (ProductID, LocationID) 1-6000 (ProductID, LocationID) 6001-12000 Data rows for ProductID 1-2000 Data rows for ProductID 2001-4000 Data rows for ProductID 4001-6000 Data rows for ProductID 6001-8000 Data rows for ProductID 80001-10000 Data rows for ProductID 10001-12000 Root Node Intermediate Level Leaf Level #SQLintheCityUK
  • 42. ProductID (Index Key) A - Z + SalesOrderID ProductID (Index Key) 1 - 150 + SalesOrderID ProductID (Index Key) 151 - 300 + SalesOrderID ProductID (Index Key) 301 - 450 + SalesOrderID ProductID (Index Key) 451 - 600 + SalesOrderID ProductID (Index Key) 601 - 750 + SalesOrderID ProductID (Index Key) 751 - 900 + SalesOrderID Root Node Intermediate Level Leaf Level ProductID (Index Key) A - M + SalesOrderID ProductID (Index Key) N - Z + SalesOrderID Lookup CarrierTrackingNumber in clustered index for each row Key Lookup SELECT ProductID , SalesOrderID , CarrierTrackingNumber FROM Sales.SalesOrderDetail WHERE ProductID = 709; #SQLintheCityUK
  • 44. #SQLintheCityUK • For small tables, scanning an index is very efficient operation • BUT…for critical and frequently-executed queries: – Provide covering non-clustered indexes that the queries can seek – Minimize logical reads (IO) required to gather the data Solution: optimize indexes for workloadSolution: optimize indexes for workload
  • 45. #SQLintheCityUK –Worst Strategy: No indexes. Query performance will be terrible –Second worst: Index on every column; same column participating in numerous indexes Data modification performance will be awful –Don’t do “SELECT *” Makes effective indexing VERY hard! Solution: optimize indexes for workloadSolution: optimize indexes for workload
  • 46. #SQLintheCityUK • Don’t index query by query • Goal: small set of indexes to help most important and frequent queries • Analyze the workload as a whole – Profiler and Database Engine Tuning Advisor • Good start point… • Not necessarily good end point – Refine recommendations using Missing Index (and other) DMVs • What is the write : read ratio (>1?) for the index? • How many plans currently associated with index? • How often are those plans used? • How many reads might the missing index have helped? Don’t create if this number is small… – See Performance Tuning with SQL Server Dynamic Management Views (free eBook) • http://bit.ly/1jVG3IW Solution: optimize indexes for workload
  • 47. “The explicit data type conversion has rendered the predicate non-SARGable!” Problem: Non-SARGable Predicates #SQLintheCityUK
  • 48. Beware of SARG-ability • Non-SARGable means that the optimizer can’t use the expression in a seek operation • Cause: use of function directly on column in WHERE or JOIN – Various incarnations – All lead to excessive IO (scans when seeks should be viable) #SQLintheCityUK
  • 49. SARG-able predicate …WHERE FirstName = 'bob';  SARGable FirstName LastName Aaron Bertrand Aaron Darrenovsky Amber Smith Apple Paltrow Bob Duffy Bob Carolgees Chris Christofferson …etc... #SQLintheCityUK
  • 50. Non SARGable predicate …WHERE REVERSE(FirstName) = 'bob'; FirstName LastName Aaron Bertrand Aaron Darrenovsky Amber Smith Apple Paltrow Bob Duffy Bob Carolgees Chris Christofferson …etc... REVERSE ('Aaron') = 'bob' ? #SQLintheCityUK
  • 51. Non SARG-able predicate …WHERE REVERSE(FirstName) = 'bob'; FirstName LastName Aaron Bertrand Aaron Darrenovsky Amber Smith Apple Paltrow Bob Duffy Bob Carolgees Chris Christofferson …etc... REVERSE ('Aaron') = 'bob' ? #SQLintheCityUK
  • 52. Non SARGable predicate …WHERE REVERSE(FirstName) = 'bob'; FirstName LastName Aaron Bertrand Aaron Darrenovsky Amber Smith Apple Paltrow Bob Duffy Bob Carolgees Chris Christofferson …etc... REVERSE ('Amber') = 'bob' ?  Non-SARGable #SQLintheCityUK
  • 54. Other common explicit conversions -- Using functions like LTRIM, RTRIM etc. -- often happens where people don't trust consistency of data inputs SELECT bp.ProductID , bp.Name , bp.ProductNumber FROM dbo.bigProduct bp WHERE LTRIM(bp.ProductNumber) LIKE 'AR%'; GO SELECT bp.ProductID , bp.Name , bp.ProductNumber FROM dbo.bigProduct bp WHERE bp.ProductNumber LIKE N'%1000'; GO #SQLintheCityUK
  • 55. Other causes of Non-SARG • Implicit Data type conversions – Variable data type doesn’t match column type – SQL Server uses CONVERT_IMPLICIT – Problem if column is lower precedence type • Data type precedence order: http://bit.ly/1ENOwjZ • Misuse of User Defined Functions (UDFs) #SQLintheCityUK
  • 56. • Rewrite the query to avoid direct use of function on column • Use helper functions • Avoid data type mismatches • Be careful when using UDFs! – Convert scalar UDFs to inline TVFs – http://bit.ly/1oN9ysK Solutions to Non-SARGability #SQLintheCityUK
  • 57. • One query size fits all • Leads to wildly inaccurate estimations and inappropriate execution plans Problem: Overly Generic SQL #SQLintheCityUK
  • 59. • Write SQL and stored procedures for a specific, defined purpose • Various ‘workarounds’ though none without drawbacks – Recompile on each execution – Dynamic SQL – See Gail Shaw’s “How to Confuse the Query Optimizer” (http://bit.ly/1Mb8Rnp) Solutions to Generic SQL #SQLintheCityUK
  • 60. Other issues that cause poor estimations • Stale statistics • Problems with parameter sniffing #SQLintheCityUK
  • 62. Conclusions • Plans tell us exactly how SQL Server executed your query – Focus on critical and frequently-executed queries – Use plans to: • spot common mistakes in the code • Uncover problems with inefficient indexing – Work with rather than against SQL Server #SQLintheCityUK
  • 63. Thank you to… • Grant Fritchey - @GFritchey • Hugo Kornelis - @Hugo_Kornelis • Gail Shaw - @SQLintheWild • Rodney Landrum - @SQLBeat • Phil Factor - @Phil_Factor #SQLintheCityUK