How to show the execution time before the query result appears

How to show execution time before query result will be displayed

0


a source to share


5 answers


If you are calling the request from code, you can use a stopwatch to request the time. Start it before executing and stop it immediately.



0


a source


Do you mean that your program displays a "Time to complete request" counter or a progress bar, for example, when you delete a large number of files in Windows Explorer?

This is not possible at all. Many requests cannot be estimated "in advance" without a significant amount of work, so the estimated completion time will not be available until the request is nearly complete.



A simple linear table lookup would be a simple case when it was possible, but adding other constraints or using indexes would cause headaches.

(Even the Windows example of deleting a large directory is fraught with problems - they need to scan the entire directory to count the files before they start deleting them so they can show you a progress bar, which is why I tend to clone large directories from the command line to to save time).

0


a source


How to show execution time before query result will be displayed

You can use "sys.dm_exec_requests", but it will only support a few of the operations listed below. Obviously it cannot support normal DML / select queries. sys.dm_exec_requests (Transact-SQL)

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.

      

0


a source


Run the request asynchronously. With ADO, it's something like this . For ADO.NET see this .

Then show the timer until you receive the Complete event.

0


a source


long inicioBusquedaLong=Calendar.getInstance().getTimeInMillis();
this.setListaTramite(this.buscarCriterio());

long finBusquedaLong=Calendar.getInstance().getTimeInMillis();
this.tiempoBusqueda=finBusquedaLong-inicioBusquedaLong;

      

0


a source







All Articles