Showing posts with label Profiler. Show all posts
Showing posts with label Profiler. Show all posts

Wednesday, February 18, 2009

FREE e-book - Mastering SQL Server Profiler

I came across this free e-book via Red Gate/SQL Server Central Database Weekly email
It is 283 pages, but looks to be a good read/tool book

Volume 2: Mastering SQL Server Profiler (10MB PDF)

I hope it's okay to list some useful contents I find (below are copied from the contents, copyright by Red Gate):
Contents 1
Getting Started with Profiler 5
The inner workings of Profiler 6
Profiler terminology 7
Getting Started with Profiler 9
Summary 21
Working with Traces and Templates 22
Understanding the Events Selection Options 22
Creating a Custom Trace from Scratch 25
Saving Traces to a SQL Server Table 35
Capturing Analysis Server Traces 37
Creating and Using Trace Templates 40
Summary 50
Profiler GUI Tips and Tricks 52
Summary 72
How to Identify Slow Running Queries 74
Creating a Trace to Identify Slow Running Queries 74
Analyzing the Poorly Performing Queries Identified by Profiler 83
Summary 94
How to Identify and Troubleshoot SQL Server Problems 95
How to Identify Deadlocks 95
How to Identify Blocking Issues 103
How to Identify Excessive Auto Stats Activity 109
How to Identify Excessive Statement Compilations 112
How to Identify Excessive Database File Growth/Shrinkage 118
How to Identify Excessive Table/Index Scans 122
How to Identify Memory Problems 126
Using Profiler to Audit Database Activity 131
Capturing Audit Events 132
Selecting Data Columns 134
Selecting Column Filters 136
Organizing Columns 137
How to Conduct an Audit Trace 138
Summary 140
Using Profiler with the Database Engine Tuning Advisor 141
Features and Benefits of Using the DTA 141 3
How to Create a Trace for Use by the DTA 142
Summary 156
Correlating Profiler with Performance Monitor 157
How to Collect Profiler Data for Correlation Analysis 157
How to Collect Performance Monitor Data for Correlation Analysis 159
How to Capture Profiler Traces and Performance Monitor Logs 170
How to Correlate SQL Server 2005 Profiler Data with Performance Monitor Data 171
How to Analyze Correlated Data 176
Summary 186
How to Capture Profiler Traces Programmatically 187
Summary 200
Profiler Best Practices 201
General Profiler Best Practices 201
Creating Traces 204
Running Traces 205
Analyzing Traces 206
Performance Monitor 207
Database Engine Tuning Advisor 208
Summary 208
Profiler Events and Data Columns Explained 209
Event Categories 209
Profiler Data Columns 274
Summary 281

Tuesday, November 25, 2008

xSQL Profiler Take 2

Today I decided to use xSQL Profiler to help me diagnose some memory pressure/paged out problems we are facing, and boy, that was probably an error (partially my fault to trace too much perhaps)

Problems:
  • I was tracing a remote server A (trace files are located on A's E drive) starting 12:30 pm
  • xSQL Profiler repository is located on my computer J, that go fetch trace files from server A
  • I think my computer cannot catch up to the trace files creation, and in ten minutes I have 6GB of trace files on server A and running low on space.
  • I killed the xSQL Profiler hoping it would stop (at this time about 80,000 rows collected)
And....
  • It did not stop!! and drove my local SQL Server memory to 1GB and slowed my laptop to a crawl
  • I could not start the "xSQL Profiler" as it says it cannot connect to the database despite being there
  • I could not start the "xSQL Profiler Service" as it creates 10+ traces insantly on server A again
  • I tried deleting entries in the local "xSQLProfiler" database tables (such as dbo.Traces, dbo.APPLICATION_SETTINGS, dbo.TRACE_SCHEDULES....) => as soon as I started xSQL Profiler, it created the 10+ traces AGAIN.
Fix:
  • Created the SQL script below to KILL ALL traces except the default one (I ran about 10 times this afternoon)
  • Renamed the trace file directory on server A's E drive [this made it stop, finally, near 3:30 pm]
  • I still cannot open up the xSQL Profiler application (cannot connect to database)
  • EXTREME CAUTION for NEXT TIME

This is the code I ended up with, and added to my toolbox
It kills ALL Profilers trace but the default SQL trace


DECLARE @traceid INT
DECLARE
curDBs CURSOR FAST_FORWARD FOR -- fast forward = read only, forward only
   --Run the following Transact-SQL statement to retrieve the list of the running trace:
  
SELECT DISTINCT traceid
  
--,*
  
FROM ::fn_trace_getinfo(NULL)   
  
WHERE traceid <> 1 -- do not kill the default SQL trace

OPEN curDBs
FETCH NEXT FROM curDBs INTO @traceid
WHILE @@FETCH_STATUS = 0
BEGIN

  
--Run the following Transact-SQL statement to stop the server-side trace
  
EXEC sp_trace_setstatus @traceid = @traceid , @status = 0
  
  
--Run the following Transact-SQL statement to close the trace and to delete the trace information
  
EXEC sp_trace_setstatus @traceid = @traceid , @status = 2

  
FETCH NEXT FROM curDBs INTO @traceid
END

CLOSE
curDBs
DEALLOCATE curDBs

SELECT * FROM ::fn_trace_getinfo(NULL)

RETURN