How can I see queries that never completed (but might have taken significant resources)?

  • Am I correct in thinking that sys.dm_exec_query_stats only includes queries that completed sucessfully? If so, is there a way to see queries that were stopped by the calling process, or rolled back, before they completed.

    Thanks

    Tim

    .

  • Yes, I think that is correct, although of course you could try it for yourself by clearing the plan cache and then running a statement that you know won't be able to finish (primary key violation, perhaps) and another where you start a transaction, run a statement and then roll back the statement.

    An alternative to the DMV you mentioned is an extended events session, which you would have to set up before the statements run.  If you specify an Event Pairing target, you can see what commands started but didn't finish.

    John

  • Tim Walker. - Friday, February 10, 2017 6:45 AM

    Am I correct in thinking that sys.dm_exec_query_stats only includes queries that completed sucessfully? If so, is there a way to see queries that were stopped by the calling process, or rolled back, before they completed.

    Thanks

    Tim

    sys.dm_exec_requests will give you the information on the current activity.
    😎

  • John Mitchell-245523 - Friday, February 10, 2017 7:09 AM

    Yes, I think that is correct, although of course you could try it for yourself by clearing the plan cache and then running a statement that you know won't be able to finish (primary key violation, perhaps) and another where you start a transaction, run a statement and then roll back the statement.

    An alternative to the DMV you mentioned is an extended events session, which you would have to set up before the statements run.  If you specify an Event Pairing target, you can see what commands started but didn't finish.

    John

    Thanks John, an event pairing target definitely looks a good option. I shall give it a go.

    Tim

    .

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

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