How can I help identify the worst performing queries in my SQL Server database application?

This is an easy task using the SQL Server Profiler.

Create a new trace in Profiler using the following configuration:

Select These Event Classes

  • SQL:BatchCompleted

Select These Data Columns

  • Groups
    • Duration
  • Columns
    • EventClass
    • TextData
    • CPU
    • Application Name
    • LoginName
    • NTUserName
    • SPID

Select These Filters (as needed)

  • Application Name
  • DatabaseName
  • Duration

As the above trace runs, you will notice that the duration of each query execution is sorted, from shortest to longest running duration. The longest running queries are at the bottom. You will very quickly be able to identify those queries that are taking a long time to run. Note: duration is measured in milliseconds. So a query that run in 1000 miliseconds takes one second to run.

Once you have identified the worst performing queries in your application, then you can start to analyze each one, trying to find ways to boost their performance. Don’t waste your time on queries that are seldom run. Instead, focus your time on those long running queries that run the most often in your application.




Related Articles :

  • No Related Articles Found

No comments yet... Be the first to leave a reply!

Software Reviews | Book Reviews | FAQs | Tips | Articles | Performance Tuning | Audit | BI | Clustering | Developer | Reporting | DBA | ASP.NET Ado | Views tips | | Developer FAQs | Replication Tips | OS Tips | Misc Tips | Index Tuning Tips | Hints Tips | High Availability Tips | Hardware Tips | ETL Tips | Components Tips | Configuration Tips | App Dev Tips | OLAP Tips | Admin Tips | Software Reviews | Error | Clustering FAQs | Performance Tuning FAQs | DBA FAQs |