Search This Blog

Showing posts with label How to Predict the DBCC SHRINK DATABASE finish time. Show all posts
Showing posts with label How to Predict the DBCC SHRINK DATABASE finish time. Show all posts
SQL Server – How to Predict the DBCC SHRINK DATABASE finish time

Question:
 I’ve issued a  DBCC SHRINKDATABASE on a 1.1 TB database. It’s been running awhile and business users are keen to know the estimated percent complete  and estimated finish time . How can I find out this information?
Answer: Using the SQL Server DMV sys.dm_exec_requests  , assists in estimating the finish time. The percent_complete and estimated_completion columns are useful.
While the DBCC SHRINKDATABASE is running – run the query below without the session_id.
Look for a record with  DbccSpaceReclaim , DbccFilesCompact or DbccLOBCompact in the command column.

SELECT session_id,percent_complete,DATEADD(MILLISECOND,estimated_completion_time,CURRENT_TIMESTAMP) Estimated_finish_time,
(total_elapsed_time/1000)/60 Total_Elapsed_Time_MINS ,
DB_NAME(Database_id) Database_Name ,command,sql_handle