find and fix sql server performance problems faster

28
THERE’S YOUR PROBLEM TROUBLESHOOTING SQL SERVER LIKE A PRO Joey D’Antoni 20 August 2015

Upload: solarwinds

Post on 26-Jan-2017

343 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Find and fix SQL Server performance problems faster

THERE’S YOUR PROBLEMTROUBLE S HOOTING SQL SERVER LIKE A PRO

Joey D’Antoni20 August 2015

Page 2: Find and fix SQL Server performance problems faster

THERE’S YOUR PROBLEM

2© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 3: Find and fix SQL Server performance problems faster

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.

Page 4: Find and fix SQL Server performance problems faster

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.

Page 5: Find and fix SQL Server performance problems faster

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.

Page 6: Find and fix SQL Server performance problems faster

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.

Page 7: Find and fix SQL Server performance problems faster

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.

Page 8: Find and fix SQL Server performance problems faster

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.

Page 9: Find and fix SQL Server performance problems faster

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.

Page 10: Find and fix SQL Server performance problems faster

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.

Page 11: Find and fix SQL Server performance problems faster

INDEXES

11© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 12: Find and fix SQL Server performance problems faster

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

Page 13: Find and fix SQL Server performance problems faster

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

Page 14: Find and fix SQL Server performance problems faster

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.

Page 15: Find and fix SQL Server performance problems faster

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.

Page 16: Find and fix SQL Server performance problems faster

DATABASE TUNING ADVISOR

16

B E V E RY C A R E F U L

© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 17: Find and fix SQL Server performance problems faster

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.

Page 18: Find and fix SQL Server performance problems faster

Physical Query Tuning

18

D E M O

© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 19: Find and fix SQL Server performance problems faster

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.

Page 20: Find and fix SQL Server performance problems faster

POLL

Do You Know xQuery?

Have you worked with xEvents?

20© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 21: Find and fix SQL Server performance problems faster

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.

Page 22: Find and fix SQL Server performance problems faster

QUERY STORE

22

S Q L S E RV E R 2 0 1 6

© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 23: Find and fix SQL Server performance problems faster

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.

Page 24: Find and fix SQL Server performance problems faster

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.

Page 25: Find and fix SQL Server performance problems faster

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.

Page 26: Find and fix SQL Server performance problems faster

QUESTIONS?

© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED. 26

Page 27: Find and fix SQL Server performance problems faster

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/

Page 28: Find and fix SQL Server performance problems faster

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