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