Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Estimation of Query Execution Time Expand / Collapse
Author
Message
Posted Wednesday, August 5, 2009 7:25 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, June 4, 2013 6:23 AM
Points: 2, Visits: 20
After issuing a query or running a stored procedure in SQL Server 2005, is there a way to know when a query/stored procedure will complete.

e.g. In file manager, when a file is copied it will mention approximately, how long it will take to complete. In oracle, looking at longops, it can be determined how much time(approximation) the query will take to complete.
Post #765429
Posted Wednesday, August 5, 2009 7:30 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, July 15, 2014 4:53 AM
Points: 2,366, Visits: 1,844
I think no but iam interested if someone can come up with something.

"Keep Trying"
Post #765435
Posted Wednesday, August 5, 2009 7:48 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 2:35 AM
Points: 5,014, Visits: 10,517
I don't think what you are asking is feasable.
The only thing I remember is a percent_complete and estimated_completion_time in sys.dm_exec_requests, but only for these commands:

ALTER INDEX REORGANIZE
AUTO_SHRINK option with ALTER DATABASE
BACKUP DATABASE
CREATE INDEX
DBCC CHECKDB
DBCC CHECKFILEGROUP
DBCC CHECKTABLE
DBCC INDEXDEFRAG
DBCC SHRINKDATABASE
DBCC SHRINKFILE
KILL (Transact-SQL)
RESTORE DATABASE,
UPDATE STATISTICS.

I don't think it can be predicted for arbitrary statements.


--
Gianluca Sartori

Get your two-cent-answer quickly
spaghettidba.com
@spaghettidba
Post #765454
Posted Wednesday, August 5, 2009 7:55 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 2:35 AM
Points: 5,014, Visits: 10,517
Uhhh.. wait: maybe you can query sys.dm_exec_query_stats and get statistics for statement you already have executed, something like:


select b.text, *
from sys.dm_exec_query_stats as a
cross apply sys.dm_exec_sql_text(sql_handle) as b

For stored procedures you could query sys.dm_exec_procedure_stats.

Hope this helps
Gianluca


--
Gianluca Sartori

Get your two-cent-answer quickly
spaghettidba.com
@spaghettidba
Post #765466
Posted Thursday, August 6, 2009 6:10 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, July 15, 2014 4:53 AM
Points: 2,366, Visits: 1,844
We can get the data related to queries already executed. I think the OP wants to know the time before executing the query.

Only way you can predict the time required is making a knowledgeable guess based on previous experience with similar queries. You can the estimated execution plan to get an idea .


"Keep Trying"
Post #766124
Posted Thursday, August 6, 2009 6:52 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 2:35 AM
Points: 5,014, Visits: 10,517
Maybe I'm wrong, but I took a look at the data returned by the view in my system and it looks like it holds statistics for sql handles of queries and procedure already executed.
If you execute the same procedure or query you could look in the dm views and guess the new execution times.


--
Gianluca Sartori

Get your two-cent-answer quickly
spaghettidba.com
@spaghettidba
Post #766150
Posted Friday, August 7, 2009 4:32 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, July 15, 2014 4:53 AM
Points: 2,366, Visits: 1,844
Hi

You are right. We can find out times of queries already executed. I assumed the OP wanted to the execution time of a new query which has not been executed even once.


"Keep Trying"
Post #766807
Posted Thursday, March 4, 2010 11:05 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, April 19, 2011 7:18 PM
Points: 40, Visits: 35
You can make something of an educated guess if, over time, you establish a relationship between 'query cost' as reported in the execution plan, and the actual time it took to execute. For example, I have an 8 proc server with 32GB RAM, 2.2Ghz cpu, on top of a small SAN configured to provide a max disk IO of 18000 Ops/sec. I have established that a query cost of 13000 units equates to roughly 5 minutes if there are no other competing operations. Note that this relationship will not be the same on any server and DB that is not exactly the same in every way.
The bottom line is that if you can establish an approximate relationship you will, under a fairly strict set of conditions, be able to predict the approximate execution time and by extension, the approximate time to complete at any point during execution. However, if you had to bet your life or job on when it would complete...don't.
Post #877388
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse