find and fix sql server performance problems faster
TRANSCRIPT
THERE’S YOUR PROBLEMTROUBLE S HOOTING SQL SERVER LIKE A PRO
Joey D’Antoni20 August 2015
THERE’S YOUR PROBLEM
2© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.
AGENDA
Performance
Wait Stats
Indexes, When and Where
Perfmon
Bringing This All Together
3
M A K I N G T H I N G S FA S T E R
© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.
FIRST THINGS FIRST
Dynamic Management Views are Your Friends
SSMS GUI offers some insight, but not nearly as much as queries and scripts
Consider using tools at scale
4
G E T C O M F O R TA B L E W I T H D M V S
© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.
PERFORMANCE TUNING SQL SERVER
DBAs get paid to backup and
restore databases
Performance usually gets
second priority due to uptime
Let’s about some
techniques to cut to the chase
5
L I K E A P R O
© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.
HOW I TUNE A SERVER
Check Server Configuration
Read Error Log
Look at Wait Stats
Look in Plan Cache
Tune Queries
6
M Y M E T H O D O L O G Y
© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.
PERFORMANCE BOTTLENECKS
CPU
Disk
Memory
Network
Blocking/Locking
7
I S TO L E T H I S F R O M TO M
© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.
UNDERSTANDING WAIT STATS
Whenever SQL Server is waiting on something it records it
Knowing how to read wait stats is the key to understanding performance
Paul Randal—Tell me where it hurts
8
T H E S E C R E T S TO S Q L P E R F O R M A N C E
© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.
WAIT STATS DEMO
9
L E T M E S E E H O W I T W O R K S
© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.
CXPACKET
Check MaxDOP
Understand Cost
Threshold for Parallelism
Understand your
workload
Dig into the plan cache
It may be natural
10
W H Y A M I A LWAY S S E E I N G T H I S
© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.
INDEXES
11© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.
TOOLS OF THE TRADE
SET STATISTICS IO ON
SET STATISTICS TIME ON
WAIT STATS
12
Q U E RY T U N I N G
WAIT STATS AND MISSING INDEXES
Large Logical Reads
PAGEIOLATCH_SH
Storage Latency
Can result in higher than usual CPU use
SP_WHOISACTIVE--Adam Machanic
13
OTHER PERFORMANCE TRICKS
Data Compression where appropriate
Columnstore for analytical workloads
Splitting workloads by disk device using filegroups
Faster SAN/More RAM
14
M A K I N G D ATA G O FA S T E R
© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.
DATA COMPRESSION
Reduces IOs needed
Incurs a CPU cost
Good for slower storage
Good for workloads with high scan rate
Impact is mainly on update
15© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.
DATABASE TUNING ADVISOR
16
B E V E RY C A R E F U L
© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.
IDENTIFYING WHICH QUERIES TO TUNE
17
D I G G I N G I N D E E P
© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.
Physical Query Tuning
18
D E M O
© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.
Execution Plans
19
C A P T U R I N G A N D U N D E R S TA N D I N G E X E C U T I O N
P L A N S
© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.
POLL
Do You Know xQuery?
Have you worked with xEvents?
20© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.
CAPTURING EXECUTION PLANS
Profiler is marked as deprecated
Extended Events ARE the path forward
Profiler is still a lot easier to use IMO
xEvents are more powerful
21
P R O F I L E R V S X E V E N T S
© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.
QUERY STORE
22
S Q L S E RV E R 2 0 1 6
© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.
WINDOWS PERFORMANCE MONITOR
Powerful Tool for holistic view of environment
Dedicated SQL Server counters
Can integrate with profiler traces
23
A K A P E R F M O N
© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.
PERFMON COUNTERS
Memory
•Available Mbytes
SQL Server:Buffer Manager
•Lazy writes/sec
•Page life expectancy
•Page reads/sec
•Page writes/sec
SQL Server:Memory Manager
•Total Server Memory (KB)
•Target Server Memory (KB)
Processor
•%Processor Time
•%Privileged Time
Process (sqlservr.exe)
•%Processor Time
•%Privileged Time
Physical Disk
•Avg. Disk sec/Read
•Avg. Disk Bytes/Read
•Avg. Disk sec/Write
•Avg. Disk Bytes/Write
Paging File
•%Usage
SQL Server:Access Methods
•Forwarded Records/sec
•Full Scans/sec
• Index Searches/sec
System
•Processor Queue Length
24
S Q L S E RV E R
© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.
PERFMON TIPS
Always run away of production server
Every 15 seconds is fine unless finding something specific
Use BLG files—can use relog to go to another format
Include Perfmon
25© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.
QUESTIONS?
© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED. 26
FREE TRIAL
• Try Database Performance Analyzer FREE for 14 days
• Improve root cause of slow performance
• Quickly identify root cause of issues that impact end-user response time
• See historical trends over days, months, and years
• Understand impact of VMware® performance
• Agentless architecture, installs in minutes
27
R E S O LV E P E R F O R M A N C E I S S U E S Q U I C K LY
© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.
www.solarwinds.com/dpa-download/
THANK YOU
© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.
The SOLARWINDS and SOLARWINDS & Design marks are the exclusive property of SolarWinds Worldwide, LLC, are registered with the U.S.
Patent and Trademark Office, and may be registered or pending registration in other countries. All other SolarWinds trademarks, service marks,
and logos may be common law marks, registered or pending registration in the United States or in other countries. All other trademarks
mentioned herein are used for identification purposes only and may be or are trademarks or registered trademarks of their respective companies.
28