Your SlideShare is downloading. ×
Perfmon And Profiler 101
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Perfmon And Profiler 101

2,824
views

Published on

Learn to use Performance Monitor and SQL Server Profiler.

Learn to use Performance Monitor and SQL Server Profiler.

Published in: Technology

1 Comment
1 Like
Statistics
Notes
No Downloads
Views
Total Views
2,824
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
85
Comments
1
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Perfmon and Profiler 101 © 2008 Quest Software, Inc. ALL RIGHTS RESERVED.
  • 2. 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
  • 3. Today’s Agenda • The Civic& Godzilla • Metrics, Trace, Mitigations • Taking Before and After Pictures • Helpful Tools • Sample Scenarios • Resources and Q&A
  • 4. If You Don’t Need to Go Fast… Photo Licensed With Creative Commons From http://flickr.com/photos/stevekeys/2755142278/
  • 5. But The Faster You Want To Go
  • 6. The More You Have To Measure
  • 7. Windows “Check Engine” Light
  • 8. And If You Wanna Go Fast:
  • 9. Two Approaches to Detection • Exceptions Monitoring: – Check Engine Light – Reactive Actions • Proactive Monitoring: – Detailed Gauges – Preventative Actions
  • 10. Metrics-Trace-Mitigation Process Capture Metrics Capture Act Trace Define Mitigations
  • 11. Where Do We Start? Hardware Windows SQL Server Tables, Indexes Query
  • 12. 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
  • 13. 12
  • 14. Memory Counters • Memory – Available Mbytes • Paging File - % Usage • SQLServer:Buffer Manager – – Buffer cache hit ratio – Page life expectancy • SQLServer:Memory Manager – Memory Grants Pending
  • 15. Storage Metrics: Physical Disk • Avg. Disk Queue Length • Avg. Disk sec/Read • Avg. Disk sec/Write • Disk Reads/sec • Disk Writes/sec • % Disk Time
  • 16. CPU & Other Metrics • Processor - % Processor Time • System – Processor Queue Length • SQLServer:General Statistics – User Connections
  • 17. The Raw Output: CSV Files 16
  • 18. Adding Analytical Formulas 17
  • 19. That’s a Lot of Zeroes! 18
  • 20. Sorting High to Low 19
  • 21. What To Look For, In Order • System – Processor Queue Length • Memory – Available Mbytes • Lock pages in memory!
  • 22. 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
  • 23. Got Everything on One Drive? • Narrow it down with the DMV sys.dm_io_virtual_file_stats
  • 24. Capture Queries with a Trace
  • 25. Columns to Capture What’s Going On What The Impact Was • Text Data • CPU • DatabaseID and/or • Reads DatabaseName • Writes • Login Name • Duration • Host Name • Start Time • Application Name • End Time
  • 26. Profiler’s Results: A Trace Table
  • 27. Order By Duration Descending
  • 28. Casting and Grouping
  • 29. Correlate Metrics & Trace • Show a cause and effect relationship • Fields to mentally “join” on: – Date/Time ranges – CPU – Reads/Writes – Duration
  • 30. Metrics-Trace-Mitigation Process Capture Metrics Capture Act Trace Define Mitigations
  • 31. If Our Servers Were Houses… Before After
  • 32. Consistent and Repeatable • 100 users accessing the web site • Closing a typical financial period • 10 users running a report • Importing 100,000 records for a nightly ETL process • Think scripts, think load generation tool • Capture statistics during test run
  • 33. When To Take A Picture Before • Adding new hardware • Installing a SQL Server service pack • Changing storage configurations After • New application versions • Every quarter
  • 34. Plus Monitoring For… Before • Things break • Populations change over time • Budgeting • Need to enforce After standards • We’re not the only ones working on the house
  • 35. Save Perfmon& Profiler Data • Central file share • Even better: in a database • Name by server, by date • Revisit every budget season • Use for new hire training
  • 36. Tool: Performance Dashboard
  • 37. Tool: Data Mining
  • 38. Table Analysis Tools For The Cloud
  • 39. Detect Categories of Load
  • 40. Works for Profiler Results Too
  • 41. Tool: ClearTrace
  • 42. Cleans Up Queries
  • 43. 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
  • 44. Ways We Can Mitigate It • Add covering indexes • Modify existing indexes • Add hard drives to the data file array • Add memory to cache scanned tables • Run reports serially, not all at once
  • 45. Sample Problem #2 • Metrics tell us: – Page file drive queue lengths average >20 – Page file use averages >1% – Available memory averages less than 250mb • Trace tells us: – No unusual queries
  • 46. Memory Configuration Server: 4gb ram OS: SQL: App: 1gb 3gb 1gb
  • 47. Ways We Can Mitigate It • Add memory and enable AWE/PAE • Add memory and upgrade to 64-bit • Move the app to its own server • Reduce SQL’s min/max memory sizes
  • 48. 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
  • 49. 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
  • 50. 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
  • 51. How We Can Mitigate It • Buy really fast processors • Spend a lot on licensing • Change cursor to set-based query
  • 52. 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 pro tools to get an edge
  • 53. Resources On The Web • My blog about Perfmon: www.BrentOzar.com/perfmon • Excel Table Analysis Tools for the Cloud: www.SQLServerDataMining.com/cloud • ClearTrace: http://www.cleardata.biz/cleartrace/ • SQL Server community: SQLServerPedia.com