When writing SQL statements, we found that there are usually many implementation methods for the desired results. In the face of these implementation methods, how should we choose to be relatively optimal? This leads to the topic of this blog. How to test the efficiency of SQL statements The following describes several ways to test the efficiency of SQL statements, most of which are searched online and tested one by one.
When writing SQL statements, we found that there are usually many implementation methods for the desired results. In the face of these implementation methods, how should we choose to be relatively optimal? This leads to the topic of this blog. How to test the efficiency of SQL statements The following describes several ways to test the efficiency of SQL statements, most of which are searched online and tested one by one.
When writing SQL statements, we found that there are usually many implementation methods for the desired results. In the face of these implementation methods, how should we choose to be relatively optimal? This introduces the topic of this blog, how to test the efficiency of SQL statements
The following describes how to test the efficiency of Several SQL statements. Most of them are searched online and tested one by one. Finally, I made a new arrangement myself.
1. Test the SQL statement execution time method to obtain the time difference before and after the query
Declare @ begin_date datetimedeclare @ end_date datetimeselect @ begin_date = getdate () select top 100 * from dbo. VA_ExperimentProjectScore --
<这里是你的语句...>
Select @ end_date = getdate () select datediff (MS, @ begin_date, @ end_date) as 'time/millisecond'
Result
2. The following method is comprehensive. The steps taken when each statement is executed are returned as a row set and displayed in the form of a hierarchy tree. The columns contained in the output are as follows:
Set statistics io onset statistics time ONgo --- select top 100 * from dbo. VA_ExperimentProjectScoregoSET STATISTICS profile offset statistics io offset statistics time OFF
Result
3. You can also set it in the tool.
Query-query option-advanced, there is a set statistics time hook, and then execute the SQL statement, read the message, there will be execution TIME