SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Estimation of Query Execution Time


Estimation of Query Execution Time

Author
Message
pattabhiy
pattabhiy
SSC Rookie
SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)

Group: General Forum Members
Points: 36 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.
ChiragNS
ChiragNS
SSCertifiable
SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)

Group: General Forum Members
Points: 6519 Visits: 1865
I think no but iam interested if someone can come up with something.

"Keep Trying"
Gianluca Sartori
Gianluca Sartori
SSC-Insane
SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)

Group: General Forum Members
Points: 23323 Visits: 13362
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

How to post T-SQL questions
spaghettidba.com
@spaghettidba
Gianluca Sartori
Gianluca Sartori
SSC-Insane
SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)

Group: General Forum Members
Points: 23323 Visits: 13362
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

How to post T-SQL questions
spaghettidba.com
@spaghettidba
ChiragNS
ChiragNS
SSCertifiable
SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)

Group: General Forum Members
Points: 6519 Visits: 1865
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"
Gianluca Sartori
Gianluca Sartori
SSC-Insane
SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)

Group: General Forum Members
Points: 23323 Visits: 13362
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

How to post T-SQL questions
spaghettidba.com
@spaghettidba
ChiragNS
ChiragNS
SSCertifiable
SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)

Group: General Forum Members
Points: 6519 Visits: 1865
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"
mike 84768
mike 84768
SSC-Enthusiastic
SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)

Group: General Forum Members
Points: 152 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.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search