Databases Reference
In-Depth Information
The execution plan in the preceding screenshot, with the analytic function and the
DISTINCT
keyword, clearly shows the steps that are performed to answer the query.
The late iltering, reducing the number of rows from
917K
to
14
, is done after the
table has been accessed and the window sort is done.
Let's compare the execution plan for the more traditional way to answer
the question.
Execution plan for the traditional query
In the execution plan shown in the preceding screenshot, you can see that the
number of rows has decreased rapidly. After executing the
HASH GROUP BY
step,
the number of rows has reduced to
1
. Also note the last column of the execution
plan—the
Time
column. For the last statement the value in the
Time
column
is signiicantly lower than the timing for the execution plan for the analytic
function query.