Learning to read the plan is outside the scope of this white paper, but in simple terms, start from the right hand side to understand what SQL Server does first. In this case, two full table scans are performed against the CLASS and REGISTRATION tables and there are 9,634 logical reads being performed.
Use logical reads metric to understand improvements
Above I mentioned the number of logical reads the query is performing. This is an important piece of data about the query execution because it provides the most fundamental metric about how much work the query is doing to retrieve the results. Even if the query performs physical reads too, remember that a logical read is performed for every physical read. Every time you execute the query, you will get the same number of logical reads assuming no changes have been made. If changes are made, the logical reads number may change and will provide an insight into the improvements.
Why not use simple execution times to measure a SQL statement? The problem with using clock time is that it is greatly influenced by other processes running at the same time you are testing the query. This can significantly impact the time a query takes to execute and thus give false impressions about possible performance gains or losses. Logical reads will not be affected in this way. The number of logical reads can be retrieved by reviewing the total_logical_reads (total reads since it was compiled) and last_logical_reads (reads from last execution) columns from the dm_exec_query_stats DMO. The command “SET STATISTICS IO ON” can also be used to get this information when executing the query.
Learning to read the plan is outside the scope of this white paper, but in simple terms, start from the right hand side to understand what SQL Server does first. In this case, two full table scans are performed against the CLASS and REGISTRATION tables and there are 9,634 logical reads being performed.
Use logical reads metric to understand improvements
Above I mentioned the number of logical reads the query is performing. This is an important piece of data about the query execution because it provides the most fundamental metric about how much work the query is doing to retrieve the results. Even if the query performs physical reads too, remember that a logical read is performed for every physical read. Every time you execute the query, you will get the same number of logical reads assuming no changes have been made. If changes are made, the logical reads number may change and will provide an insight into the improvements.
Why not use simple execution times to measure a SQL statement? The problem with using clock time is that it is greatly influenced by other processes running at the same time you are testing the query. This can significantly impact the time a query takes to execute and thus give false impressions about possible performance gains or losses. Logical reads will not be affected in this way. The number of logical reads can be retrieved by reviewing the total_logical_reads (total reads since it was compiled) and last_logical_reads (reads from last execution) columns from the dm_exec_query_stats DMO. The command “SET STATISTICS IO ON” can also be used to get this information when executing the query.
การแปล กรุณารอสักครู่..
