perfmon and profiler 101

45
© 2008 Quest Software, Inc. ALL RIGHTS RESERVED. Perfmon and Profiler 101

Upload: sunee

Post on 11-Jan-2016

37 views

Category:

Documents


0 download

DESCRIPTION

Perfmon and Profiler 101. About Me: Brent Ozar. SQL Server Expert for Quest Software Former SQL DBA Managed >80tb SAN, VMware Dot-com-crash experience Specializes in performance tuning. Today’s Agenda. The Honda Civic and the Nissan GT-R Metrics, Trace, Mitigations A New Secret Weapon - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Perfmon and Profiler 101

© 2008 Quest Software, Inc. ALL RIGHTS RESERVED.

Perfmon and Profiler 101

Page 2: Perfmon and Profiler 101

About Me: Brent Ozar

• SQL Server Expert for Quest Software

• Former SQL DBA

• Managed >80tb SAN, VMware

• Dot-com-crash experience

• Specializes in performance tuning

Page 3: Perfmon and Profiler 101

Today’s Agenda

• The Honda Civic and the Nissan GT-R

• Metrics, Trace, Mitigations

• A New Secret Weapon

• Resources and Q&A

Page 4: Perfmon and Profiler 101

If You Don’t Need to Go Fast…

From http://flickr.com/photos/stevekeys/2755142278/

Page 5: Perfmon and Profiler 101

But The Faster You Want To Go

Page 6: Perfmon and Profiler 101

The More You Have To Measure

Page 7: Perfmon and Profiler 101

Windows “Check Engine” Light

Page 8: Perfmon and Profiler 101

And If You Wanna Go Fast:

Page 9: Perfmon and Profiler 101

Two Approaches to Detection

• Exceptions Monitoring: Check Engine

• Proactive Monitoring: Detailed Gauges

Page 10: Perfmon and Profiler 101

Where Do We Start?

Page 11: Perfmon and Profiler 101

Capture Metrics With Perfmon

• Performance Monitor, aka Perfmon

• Ships with all Windows versions

• Polls any server from your desktop

• Pulls performance metrics

• Writes them to a file

• Requires some OS permissions

• Does not include alerts or analytics

Page 12: Perfmon and Profiler 101

12

Page 13: Perfmon and Profiler 101
Page 14: Perfmon and Profiler 101

Memory Counters

• Memory – Available Mbytes

• Paging File - % Usage

• SQLServer:Buffer Manager – – Buffer cache hit ratio– Page life expectancy

• SQLServer:Memory Manager – Memory Grants Pending

Page 15: Perfmon and Profiler 101

Storage Metrics: Physical Disk

• % Disk Time

• Avg. Disk Queue Length

• Avg. Disk sec/Read

• Avg. Disk sec/Write

• Disk Reads/sec

• Disk Writes/sec

Page 16: Perfmon and Profiler 101

CPU Metrics

• Processor - % Processor Time

• System – Processor Queue Length

• SQLServer:General Statistics – User Connections (not CPU, just “other”)

Page 17: Perfmon and Profiler 101

17

The Raw Output: CSV Files

Page 18: Perfmon and Profiler 101

18

Adding Analytical Formulas

Page 19: Perfmon and Profiler 101

19

That’s a Lot of Zeroes!

Page 20: Perfmon and Profiler 101

20

Sorting High to Low

Page 21: Perfmon and Profiler 101

What To Look For, In Order

• System – Processor Queue Length

• Memory – Available Mbytes

• Lock pages in memory!

Page 22: Perfmon and Profiler 101

What To Look For Next

• Disk metrics on the page file drive

• Disk metrics on the log file drive

• Disk metrics on the data file drive

• Disk metrics on the TempDB drive

Page 23: Perfmon and Profiler 101

Got Everything on One Drive?

• Narrow it down with the DMV sys.dm_io_virtual_file_stats

Page 24: Perfmon and Profiler 101

What If We Could Data Mine It?

Page 25: Perfmon and Profiler 101

Table Analysis Tools For The Cloud

Page 26: Perfmon and Profiler 101

Detecting Categories of Load

Page 27: Perfmon and Profiler 101

Capture Queries with a Trace

Page 28: Perfmon and Profiler 101

Columns to Capture

What’s Going On

• Text Data• DatabaseID and/or

DatabaseName• Login Name• Host Name• Application Name

What The Impact Was

• CPU• Reads• Writes• Duration• Start Time• End Time

Page 29: Perfmon and Profiler 101

Profiler’s Results: A Trace Table

Page 30: Perfmon and Profiler 101

Order By Duration Descending

Page 31: Perfmon and Profiler 101

Casting and Grouping

Page 32: Perfmon and Profiler 101

Another Cloud Analytics Candidate

Page 33: Perfmon and Profiler 101

Another Way: Perf Dashboard

Page 34: Perfmon and Profiler 101

Correlate Metrics & Trace

• Show a cause and effect relationship

• Fields to mentally “join” on:– Date/Time ranges– CPU– Reads/Writes– Duration

Page 35: Perfmon and Profiler 101

Sample Problem #1

• Metrics tell us:– Very high disk queue

lengths on data drive

• Trace tells us:– Report queries doing

table scans w/o indexes– Many scheduled reports

run simultaneously

Page 36: Perfmon and Profiler 101

Ways We Can Mitigate It

• Add covering indexes

• Modify existing indexes

• Run reports serially, not all at once

• Add hard drives to the data file array

• Add memory to cache scanned tables

Page 37: Perfmon and Profiler 101

Sample Problem #2

• Metrics tell us:– Page file drive queue lengths

average >20– Page file use averages >1%– Available memory averages

<200mb– Buffer cache hit ratio and

page life expectancy are high

• Trace tells us:– No unusual queries

Page 38: Perfmon and Profiler 101

Memory Configuration

Page 39: Perfmon and Profiler 101

Ways We Can Mitigate It

• Add memory and enable AWE/PAE

• Add memory and upgrade to 64-bit

• Reduce SQL’s min/max memory sizes

• Move the app to its own server

Page 40: Perfmon and Profiler 101

Sample Problem #3

• Metric looks OK, but every 15 minutes:– Long drive queues on the

log file drive– Page life expectancy

drops near zero– Network traffic jumps

• Trace tells us:– Transaction log backups

are running

Page 41: Perfmon and Profiler 101

Ways We Can Mitigate It

• Stop doing log backups

• Put the databases in simple mode

• Add drives to the transaction log array

• Throttle the transaction log backups

Page 42: Perfmon and Profiler 101

Sample Problem #4

• Metrics tell us:– CPU average is high – Disk, memory look OK

• Trace tells us:– Queries are using

cursors– Operating on

individual records, not sets

Page 43: Perfmon and Profiler 101

How We Can Mitigate It

• Change cursor to set-based query

• Buy really fast processors

• Spend a lot on licensing

Page 44: Perfmon and Profiler 101

Wrapping Things Up

• Double-check the event log first

• Don’t get overwhelmed: focus with the Metric – Trace – Mitigation process

• Show a clear cause and effect

• Use cloud-based BI to get an edge

Page 45: Perfmon and Profiler 101

Resources On The Web

• My posts about Perfmon and analytics:www.BrentOzar.com/perfmonwww.BrentOzar.com/perfmoncloud

• Excel Table Analysis Tools for the Cloud:www.SQLServerDataMining.com/cloud

• SQL Server community:SQLServerPedia.com