solating a Long-Running Query with SQL Profiler

If your application has a performance problem that you think might be caused by a particularly long-running query, you can use the SQLProfilerTSQL_Duration template to analyze query durations. You can either analyze the queries interactively, or you can save information to an output file and analyze the data offline.

Identifying a Long-Running Query Interactively

The most immediate way of analyzing query performance is to use SQL Profiler to show trace information interactively.

To identify a long-running query interactively

Identifying a Long-Running Query from Trace Output

As an alternative to the interactive approach, you can save trace information to an output file and analyze the data offline. The trace information can then be imported into a database table for further analysis. This approach is useful where large sets of trace data need to be analyzed.

The following steps show you how to save trace data to a trace file and then import it into a trace table for analysis. A stored procedure named AnlzTrcExec is provided to aid in data analysis.

Note   When trace data is saved to a file, the values in the EventClass column are converted into integer values. To increase readability, the AnlzTrcExec procedure uses a lookup table named trace_events so that the event class can be displayed as text.

To identify a long-running query from trace output

_______________________________________________________________________________-

I’ve observed that as part of different incident(s), service requests, performance issues that we work on, very often requirement is to setup a SQL Profiler Trace to investigate on the issue. It is very important to interpret profile extract and only when we do that, our purpose is achieved else we are back to square one. I always recommend minimum events (using this word carefully) with appropriate filters considering the volume of data that are captured when we run a profiler so that it doesn't become unmanageable better we call it a PUZZLE.

 

 profiler events to understand how they can benefit us in troubleshooting different scenarios and following are my observations however you are free to add your own selections, but these are the primary counters we rely on.

 

Deadlocks/ Blocking

 

Lock: Deadlock

Lock: Deadlock Chain

Deadlock Graph

RPC: Completed

SQL: BatchCompleted

 

Blocked Process Report (Use if you only have to capture blockings)

 

General Performance Tuning issues

 

SP: StmtCompleted

RPC: Completed

SQL: BatchCompleted

Showplan XML

 

 

Long running queries

 

RPC: Completed

SQL: BatchCompleted

SP: StmtCompleted

 

 

Note : We can always add more events based on our requirement.