August 1, 2011 at 1:42 pm
I know the query from app hits two tables. I need to send an email out if query takes more than 15s to execute.
ANy idea how to figure out the query running more than 15s?
Thanks for your help.
August 1, 2011 at 2:17 pm
this will show you any queries that are in the DMV cache that ever had a elapsed time of more than 15 seconds.
you could refine it from there, but this would get you started, at least.
note that items in the DMV can be aged out, so you could miss long running queries that were not in cache; to be complete, Grant Fitchey suggests a server side trace so you can query that in this article:
http://www.sqlservercentral.com/articles/Performance/71549/
USE master;
GO
select
fn.*,
st.*
from sys.dm_exec_query_stats st
cross apply sys.dm_exec_sql_text(st.[sql_handle]) fn
where st.max_elapsed_time >= (1000 * 15) --15 seconds
Lowell
August 1, 2011 at 7:26 pm
Thanks. But I need somthing that is currently executing and it is executing longer than 15 second. Not the ones which aare done execution.
August 1, 2011 at 7:52 pm
i think you have to wait until something is executed first...it may have completed a second ago, but i don't think the dmv will return what is currently executing, just items that completed.
Lowell
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply