I am new to SQL Server and am trying to optimize some multi-table
queries. My question involves the very time costly step the ShowPlan
indicates is being done at the end of my query.
My query joins 6 tables together, does some GROUP BY action, and dumps
the results (1148 rows) in Worktable 4. The ShowPlan shows the following
final step for my query:
The type of query is SELECT
The table hit stats show the following very large numbers for Worktable
scan count 109715,
logical reads: 577378,
physical reads: 69056,
read ahead reads: 0
This query takes 17 minutes (one of the tables has 3.6 million rows),
and judging by the large number of physical reads being done to
Worktable 4, a good part of this time may be spent doing this last step.
What exactly is this step doing? Is this what it does to read each row
from Worktable 4 and send it to my query window in Enterprise Manager?
Also, the table stats are given for what is called disk READS, but how
many of these logical and physical reads are actually occurring in the
WRITING of rows into Worktable 4?
Thanks a lot for any help,