hmm, I saw some books or article says the execution plan is inaccurate , if like this how we can compare which sql statement is better ?
I used actual execution plan in my test. thanks!
Execution plans accurately portray "estimates" (and some actuals) if you understand the irony in that statement, which can be wildly different than what actually happens. Even the "Actual" Execution Plan is riddled with estimates.
You can use execution plans to see things like which indexes are going to be or have been used and are a very effective development tool BUT... the only way to tell which code is actually "better" for the likes of CPU, Duration, Reads, Writes, and Memory Usage is to actually run the code and measure it using SQL Profiler, Extended Events, or, if you're careful with what you're measuring (shouldn't be used when things like Scalar UDFs or mTVFs are present, for example), SET STATISTICS.
is pronounced "ree-bar
" and is a "Modenism
" for R
First step towards the paradigm shift of writing Set Based code:
________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
"Change is inevitable... change for the better is not".
"Dear Lord... I'm a DBA so please give me patience because, if you give me strength, I'm going to need bail money too!"
How to post code problems
How to Post Performance Problems
Create a Tally Function (fnTally)