查看剩余执行时间


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

在创建索引,数据库恢复等耗时操作时,可通过以下方法查看剩余时间

  1. SELECT
  2.     d.PERCENT_COMPLETE AS [%Complete],
  3.     d.TOTAL_ELAPSED_TIME/60000 AS ElapsedTimeMin,
  4.     d.ESTIMATED_COMPLETION_TIME/60000   AS TimeRemainingMin,
  5.     d.TOTAL_ELAPSED_TIME*0.00000024 AS ElapsedTimeHours,
  6.     d.ESTIMATED_COMPLETION_TIME*0.00000024  AS TimeRemainingHours,
  7.     s.text AS Command
  8. FROM    sys.dm_exec_requests d
  9. CROSS APPLY sys.dm_exec_sql_text(d.sql_handle)as s
  10. WHERE  d.COMMAND LIKE 'RESTORE DATABASE%'
  11. ORDER   BY 2 desc3 DESC    
  12. 可统计为以下命令完成的工作的百分比:

    • ALTER INDEX REORGANIZE
       
    • AUTO_SHRINK 选项(带 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.