views:

80

answers:

1

Hello,

I saw a similar question which asked how to monitor the progress of a backup / restore operation: http://stackoverflow.com/questions/152447/is-there-a-sql-script-that-i-can-use-to-determine-the-progress-of-a-sql-server-ba

I would like to know if there's a similar query / way to see how much time the query has left until it will end. For example, one query usually has elapsed time of 5 minutes. I would like to know how much time is left until it will end DURING the query's execution.

Thanks in advance, Roni.

+4  A: 

there is no way to know how much time is left. a query's run time depends on many things beyond the actual query itself: locking/blocking of other queries, other processes consuming resources (cpu/disk usage), the operating system, network, etc. What if your 5 minute query is running, yet someone else kicks off a large report, your query may run 5:30 now. What if the someone starts to download a large file and hogs all the network bandwidth? What if the OS decides to do something in the background, etc. Until all the rows are returned, the query isn't done, but it can run in an variable time frame.

KM
Indeed. On some (badly configured/overloaded) systems, a single intensive query can lock a crucial table - and all of a sudden, queries that usually finish under a second run for tens of minutes. You could watch the query times and provide a guess - "on average, this query completes in 5:41, it's been running for 3:15 now", but it's just that: a guess (not even an estimate).
Piskvor
I've seen 3D rendering screen savers running on production database boxes!
KM
In Oracle for example, we have the view v$session_longops, which displays the status of operations.http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/dynviews_2092.htmI you sure there's no similar thing in SQL SERVER ?Roni.
Roni Vered
@Roni Vered, there are numerous ways to get info from SQL Server about running queries, but no "TIME_RAMINING" value. You may be able to calculate an average value based on previous runs, see: http://stackoverflow.com/questions/617170/query-duration-estimation-in-sql-server
KM
OK. thanks a lot for your effort.
Roni Vered