Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Query duration estimation in SQL Server

I've seen in Oracle 10g a feature that estimates the remaining time for a long running query and I was wondering if this is possible too in SQL Server (at least in 2008?)?

Suppose I have a very large table with tens of millions of rows (well indexed etc. etc.) and I need to search for some particular rows. I know it will take a lot of time and I'm cool with that but I would like to present the user with some kind of a progress bar.

How can I show progress?

like image 792
Andrei Rînea Avatar asked Mar 05 '09 23:03

Andrei Rînea


People also ask

How do I find the query completion time in SQL Server?

Using Client StatisticsGo to Menu >> Query >> Select Include client Statistics. Execute your query. In the results panel, you can see a new tab Client Statistics. Go to the Client Statistics tab to see the execution time.

What is estimated execution plan in SQL Server?

Estimated execution plans Without executing the query, you can obtain an estimated (logical) SQL Server execution plan based on SQL Server statistics. In SQL Server Management Studio (SSMS) follow these steps: Highlight the query (in case you want the execution plan for a specific query).

What is query elapsed time?

The elapsed time is the total time taken by SQL Server. The set statistics time statement reports elapsed times separately for parse and compile operations as well as the execution of a compiled plan. The elapsed time is how long the operation (either parse and compile or execution of the compile plan) takes overall.


1 Answers

I'd forget about it and just put a spinning circle!

Seriously though, to take MrTelly's idea further, there are dynamic management views that can give you average execution times for certain queries - maybe that can get you somewhere.

http://msdn.microsoft.com/en-us/library/ms188754.aspx

edit: I have seen percent complete in the sp_whoisactive procedure from Adam Machanic. Maybe that is another place to look into. SQL 2016 has the query store which persists plan cache information - a substitute for the dmv plan cache, which is cleared on reboot.

like image 51
Sam Avatar answered Sep 23 '22 12:09

Sam