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?
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.
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).
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With