您的位置:首页 > 数据库

查看Sql Server语句执行效率,时间的方法

2014-08-12 10:00 971 查看
This tutorial proposes 3 ways in order for you to get the Execution time of SQL Query or Stored Procedures are called or submitted to your SQL Server.

They will give you durations in microseconds and base on the execution time, you may have a deeper understand and will do some optimization for your database structure/indexing to make it runs better.

1. Using SQL Server Profiler

I think it’s a easiest way for you to trace/track Which
Stored Procedures Or SQL Commands Are Running On SQL Server and how long it takes for each of SQL Query/ Stored Procedure execution.





SQL Server Profiler Execution Time

As you see, all commands are in TextData column and all Execution time for each are in Duration column respectively.

2. Using SQL Script with @StartTime and @EndTime parameters

The script should be run on SQL Server Management Studio Query.

?
Just replace your own SQL statements with line 2, after execute the statement, it will show the Duration in microseconds in another result panel.





Get Execution Time With Start Time And End Time

3. Using SQL Script with SET STATISTICS TIME (Transact-SQL)

It displays the number of milliseconds required to parse, compile, and execute each statement.

Run this SQL script on your SQL Query:

?
And below is the result set:

?




Get Execution Time With SET STATISTICS TIME

That’s all! Feel free to contribute your own solution by submitting your comments as you’re always be welcome.
- See more at: http://4rapiddev.com/sql-server/capture-and-display-execution-time-of-sql-query-in-sql-server/#sthash.OgMz1Qq4.dpuf
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: