Calculate execution time of a SQL query?

前端 未结 8 435
悲&欢浪女
悲&欢浪女 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 14:56

    We monitor this from the application code, just to include the time required to establish/close the connection and transmit data across the network. It's pretty straight-forward...

    Dim Duration as TimeSpan
    Dim StartTime as DateTime = DateTime.Now
    
    'Call the database here and execute your SQL statement
    
    Duration = DateTime.Now.Subtract(StartTime)
    Console.WriteLine(String.Format("Query took {0} seconds", Duration.TotalSeconds.ToString()))
    Console.ReadLine()

提交回复
热议问题