Calculate execution time of a SQL query?

前端 未结 8 425
悲&欢浪女
悲&欢浪女 2020-12-04 14:17

I am providing search functionality in my website, when user searches a record then I want to display the time the query taken to get the results same as google does. When w

相关标签:
8条回答
  • 2020-12-04 15:02

    Please use

    -- turn on statistics IO for IO related 
    SET STATISTICS IO ON 
    GO
    

    and for time calculation use

    SET STATISTICS TIME ON
    GO
    

    then It will give result for every query . In messages window near query input window.

    0 讨论(0)
  • 2020-12-04 15:07

    You can use

    SET STATISTICS TIME { ON | OFF }
    

    Displays the number of milliseconds required to parse, compile, and execute each statement

    When SET STATISTICS TIME is ON, the time statistics for a statement are displayed. When OFF, the time statistics are not displayed

    USE AdventureWorks2012;  
    GO         
    SET STATISTICS TIME ON;  
    GO  
    SELECT ProductID, StartDate, EndDate, StandardCost   
    FROM Production.ProductCostHistory  
    WHERE StandardCost < 500.00;  
    GO  
    SET STATISTICS TIME OFF;  
    GO  
    
    0 讨论(0)
提交回复
热议问题