Perfmon And Profiler 101


Published on

Published in: Technology
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Perfmon And Profiler 101

  1. 1. Perfmon and Profiler 101<br />
  2. 2. About Me: Brent Ozar<br />SQL Server Expert for Quest Software<br />Former SQL DBA<br />Managed &gt;80tb SAN, VMware<br />Dot-com-crash experience<br />Specializes in performance tuning<br />
  3. 3. Today’s Agenda<br />The Civic & Godzilla<br />Metrics, Trace, Mitigations<br />Taking Before and After Pictures<br />Helpful Tools<br />Sample Scenarios<br />Resources and Q&A<br />
  4. 4. If You Don’t Need to Go Fast…<br />Photo Licensed With Creative Commons From<br />
  5. 5. But The Faster You Want To Go<br />
  6. 6. The More You Have To Measure<br />
  7. 7. Windows “Check Engine” Light<br />
  8. 8. And If You Wanna Go Fast:<br />
  9. 9. Two Approaches to Detection<br />Exceptions Monitoring: <br />Check Engine Light<br />Reactive Actions<br />Proactive Monitoring: <br />Detailed Gauges<br />Preventative Actions<br />
  10. 10. Metrics-Trace-Mitigation Process<br />
  11. 11. Where Do We Start?<br />
  12. 12. Capture Metrics With Perfmon<br />Performance Monitor, aka Perfmon<br />Ships with all Windows versions<br />Polls any server from your desktop<br />Pulls performance metrics<br />Writes them to a file<br />Requires some OS permissions<br />Does not include alerts or analytics<br />
  13. 13. 12<br />
  14. 14. Memory Counters<br />Memory – Available Mbytes<br />Paging File - % Usage<br />SQLServer:Buffer Manager – <br />Buffer cache hit ratio<br />Page life expectancy<br />SQLServer:Memory Manager – Memory Grants Pending<br />
  15. 15. Storage Metrics: Physical Disk<br />Avg. Disk Queue Length<br />Avg. Disk sec/Read<br />Avg. Disk sec/Write<br />Disk Reads/sec<br />Disk Writes/sec<br />% Disk Time<br />
  16. 16. CPU & Other Metrics<br />Processor - % Processor Time<br />System – Processor Queue Length<br />SQLServer:General Statistics – User Connections<br />
  17. 17. 16<br />The Raw Output: CSV Files<br />
  18. 18. 17<br />Adding Analytical Formulas<br />
  19. 19. 18<br />That’s a Lot of Zeroes!<br />
  20. 20. 19<br />Sorting High to Low<br />
  21. 21. What To Look For, In Order<br />System – Processor Queue Length<br />Memory – Available Mbytes<br />Lock pages in memory!<br />
  22. 22. What To Look For Next<br />Disk metrics on the page file drive<br />Disk metrics on the log file drive<br />Disk metrics on the data file drive<br />Disk metrics on the TempDB drive<br />
  23. 23. Got Everything on One Drive?<br />Narrow it down with the DMV sys.dm_io_virtual_file_stats<br />
  24. 24. Capture Queries with a Trace<br />
  25. 25. Columns to Capture<br />What’s Going On<br />Text Data<br />DatabaseID and/or DatabaseName<br />Login Name<br />Host Name<br />Application Name<br />What The Impact Was<br />CPU<br />Reads<br />Writes<br />Duration<br />Start Time<br />End Time<br />
  26. 26. Profiler’s Results: A Trace Table<br />
  27. 27. Order By Duration Descending<br />
  28. 28. Casting and Grouping<br />
  29. 29. Correlate Metrics & Trace<br />Show a cause and effect relationship<br />Fields to mentally “join” on:<br />Date/Time ranges<br />CPU<br />Reads/Writes<br />Duration<br />
  30. 30. Metrics-Trace-Mitigation Process<br />
  31. 31. If Our Servers Were Houses…<br />Before<br />After<br />
  32. 32. Consistent and Repeatable<br />100 users accessing the web site<br />Closing a typical financial period<br />10 users running a report<br />Importing 100,000 records for a nightly ETL process<br />Think scripts, think load generation tool<br />Capture statistics during test run<br />
  33. 33. When To Take A Picture<br />Before<br />Adding new hardware<br />Installing a SQL Server service pack<br />Changing storage configurations<br />New application versions<br />Every quarter<br />After<br />
  34. 34. Plus Monitoring For…<br />Before<br />Things break<br />Populations change over time<br />Budgeting<br />Need to enforce standards<br />We’re not the only ones working on the house<br />After<br />
  35. 35. Save Perfmon & Profiler Data<br />Central file share<br />Even better: in a database<br />Name by server, by date<br />Revisit every budget season<br />Use for new hire training<br />
  36. 36. Tool: Performance Dashboard<br />
  37. 37. Tool: Data Mining<br />
  38. 38. Table Analysis Tools For The Cloud<br />
  39. 39. Detect Categories of Load<br />
  40. 40. Works for Profiler Results Too<br />
  41. 41. Tool: ClearTrace<br />
  42. 42. Cleans Up Queries<br />
  43. 43. Sample Problem #1<br />Metrics tell us:<br />Very high disk queue lengths on data drive<br />Trace tells us:<br />Report queries doing table scans w/o indexes<br />Many scheduled reports run simultaneously<br />
  44. 44. Ways We Can Mitigate It<br />Add covering indexes<br />Modify existing indexes<br />Add hard drives to the data file array<br />Add memory to cache scanned tables<br />Run reports serially, not all at once<br />
  45. 45. Sample Problem #2<br />Metrics tell us:<br />Page file drive queue lengths average &gt;20<br />Page file use averages &gt;1%<br />Available memory averages less than 250mb<br />Trace tells us:<br />No unusual queries<br />
  46. 46. Memory Configuration<br />
  47. 47. Ways We Can Mitigate It<br />Add memory and enable AWE/PAE<br />Add memory and upgrade to 64-bit<br />Move the app to its own server<br />Reduce SQL’s min/max memory sizes<br />
  48. 48. Sample Problem #3<br />Metric looks OK, but every 15 minutes:<br />Long drive queues on the log file drive<br />Page life expectancy drops near zero<br />Network traffic jumps<br />Trace tells us:<br />Transaction log backups are running<br />
  49. 49. Ways We Can Mitigate It<br />Stop doing log backups<br />Put the databases in simple mode<br />Add drives to the transaction log array<br />Throttle the transaction log backups<br />
  50. 50. Sample Problem #4<br />Metrics tell us:<br />CPU average is high <br />Disk, memory look OK<br />Trace tells us:<br />Queries are using cursors<br />Operating on individual records, not sets<br />
  51. 51. How We Can Mitigate It<br />Buy really fast processors<br />Spend a lot on licensing<br />Change cursor to set-based query<br />
  52. 52. Wrapping Things Up<br />Double-check the event log first<br />Don’t get overwhelmed: focus with the Metric – Trace – Mitigation process<br />Show a clear cause and effect<br />Use pro tools to get an edge<br />
  53. 53. Resources On The Web<br />My blog about<br />Excel Table Analysis Tools for the<br />ClearTrace:<br />SQL Server<br />