Based on popular demand from my colleagues and you, the kind reader, I am currently writing a series of posts on the SQL Server Profiler. Five parts have been published till date, and for your kind reference, here are the links to them:
- What is a SQL Trace? Permissions, space requirements and launching the Profiler
- Profiler Templates, Template Types & creating custom templates
- Trace execution options – Save trace to file or a table, Auto-scroll and keyboard shortcuts
- Review T-SQL code to identify objects no longer supported by Microsoft – Deprecation Event
- Replaying a trace – from a file or a table – using breakpoints during trace replay
Today, in the last part of the series, we will be looking at another important application of the SQL Server Profiler – Correlating the Profiler Trace with Windows Profiler Log Data. This is helpful when you, as an IT or database administrator suspect that SQL Server is either being held up by or is the cause of an I/O, memory or processor contention.
Windows Reliability & Performance Monitor Log Data
Windows Reliability and Performance Monitor is a Microsoft Management Console (MMC) snap-in that combines the functionality of previous stand-alone tools including Performance Logs and Alerts, Server Performance Advisor, and System Monitor. The tool of interest to us is the Performance Logs and Alerts, erstwhile known as “Perfmon”.
Because this is a post on the SQL Server Profiler, demonstrating the capture of data using the Windows Reliability and Performance Monitor is out of scope. You may refer the References section for more details on the Windows Reliability and Performance Monitor.
For this test, I have created a Performance trace of the following counters (because the goal of this exercise was just to have a demonstration, very basic counters have been chosen. Under “live” circumstances, the counter range would be different):
- Total Disk – Reads/sec
- Total Disk – Writes/sec
- Total Disk – Current Queue Length
- SQL Server Buffer Manager – Page reads/sec
- SQL Server Buffer Manager – Page writes/sec
SQL Server Profiler Trace Data
Using the custom trace developed in earlier editions of this series, capture a SQL Server Profiler Log for the following script. Notice that the script has been designed to have a distinct set of read & write activities:
/********************************************** !!!! WARNING !!!! THIS SCRIPT IS PROVIDED AS-IS AND WITHOUT WARRANTY. THE AUTHOR AND BEYONDRELATIONAL.COM ARE NOT RESPONSIBLE FOR ANY DAMANGE CAUSED BY THE USE OF THIS SCRIPT. **********************************************/ USE tempdb GO CREATE TABLE DefaultTableTest ( DataId INT IDENTITY(1,1), RandomId INT DEFAULT (RAND()*1000), DataName VARCHAR(10) DEFAULT 'DEFAULT' ) GO /****************************************** Insert some test data into the table - This should generate lots of writes ******************************************/ USE tempdb GO INSERT INTO DefaultTableTest DEFAULT VALUES GO 20000 /****************************************** Fetch the test data - This should generate lots of reads! ******************************************/ USE tempdb GO SELECT * FROM DefaultTableTest GO SELECT * FROM AdventureWorks2008R2.HumanResources.Employee GO --Wait for some time WAITFOR DELAY'00:00:20' --Regenerate some activity USE tempdb GO SELECT * FROM DefaultTableTest GO SELECT * FROM AdventureWorks2008R2.HumanResources.Employee GO
It is important to remember that the time ranges for the Windows Performance Monitor Log and SQL Server Profiler Trace log must overlap for the Profiler to be able to correlate them.
Correlating the Profiler Trace with Windows Performance Log Data
Once the data has been collected, now is the time to correlate the Profiler trace with the Windows Performance Log data. Below are the steps that you can use to do so:
NOTES:
- The time ranges of the Profiler & Windows Performance Log data must overlap
- For accurate correlation with System Monitor data, the trace must contain both StartTime and EndTime data columns
- Correlation of the Profiler & Windows Performance Log data is not possible for a running trace that is still active & collecting data
References:
- Windows Reliability & Performance Monitor – http://technet.microsoft.com/en-us/library/cc749249(WS.10).aspx
- Correlate a trace with Windows Performance Log Data – http://msdn.microsoft.com/en-us/library/ms191152.aspx
- All uses of the Profiler – http://msdn.microsoft.com/en-us/library/ms181091(SQL.110).aspx
- Profiler keyboard shortcuts – http://msdn.microsoft.com/en-us/library/ms174164.aspx
I hope you liked reading all 6 parts of my series on the SQL Server Profiler. Do leave your feedback – I really appreciate and thank-you for taking the time out of your busy day to read my posts.
Until we meet next time,
Be courteous. Drive responsibly.
Subscribe to my posts via E-mail: Subscribe here | Read my posts via your favourite RSS reader: Click Here!