SQL Profiler - Can it tell you how long query was blocked for

  • Hi, I often have situations where a lot of queries time out. However most queries time out because they are blocked by other long running queries, rather than themselves taking a long time to run (due to table scans etc). Is there any way to get SQL profiler to indicate only those queries that have long durations only as a result of themselves taking a long time to run, rather than spending all their time blocked?

    Thanks

    http://90.212.51.111 domain

  • I don't believe that there is a way to do that directly in profiler. I think you could figure that out by using a combination of the lock timeout event and the CPU and duration columns of the SP:Completed or SQL:StmtCompleted events as I do not believe a process waiting for a lock to be released is using CPU time.

  • just a point here - generally queries only time out from the client dropping the connection not as an internal SQL Server operation unless it's a deadlock. If you set a block using a couple of sql queries you'll find they'll tend to sit there until the end of time.

    I run a profiler which captures long running queries based upon duration, but you won't really know a query is long running until it's finished.

    It's not difficult to query the dmvs to gather what you need either but sorting out waht's blocked and just running may be trickier

    [font="Comic Sans MS"]The GrumpyOldDBA[/font]
    www.grumpyolddba.co.uk
    http://sqlblogcasts.com/blogs/grumpyolddba/

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply