Measuring Query Performance : “Execution Plan Query Cost” vs “Time Taken”

前端 未结 6 985
天涯浪人
天涯浪人 2020-11-29 20:10

I\'m trying to determine the relative performance of two different queries and have two ways of measuring this available to me:
1. Run both and time each query
2. Ru

6条回答
  •  猫巷女王i
    2020-11-29 20:47

    Query Execution Time:

    DECLARE @EndTime datetime
    DECLARE @StartTime datetime 
    SELECT @StartTime=GETDATE() 
    
    
    ` -- Write Your Query`
    
    SELECT @EndTime=GETDATE()
    --This will return execution time of your query
    SELECT DATEDIFF(MILLISECOND,@StartTime,@EndTime) AS [Duration in millisecs] 
    

    Query Out Put Will be Like:

    enter image description here

    To Optimize Query Cost :

    Click on your SQL Management Studio

    enter image description here

    Run your query and click on Execution plan beside the Messages tab of your query result. you will see like

    enter image description here

提交回复
热议问题