I have the following query which I'm using to review the SQL Server execution plan.
SELECT TOP 1000
fact.division,
case when fact.division='east' then 'XXX' else 'YYY' end div,
count(1)
FROM
division join fact on (division.division=fact.division)
where
fact.division!='east'
group by
fact.division
And the plan is as follows:
I have a few questions about the plan:
- Why does it do a Sort before the Aggregate?
- What are the two Stream Aggregate operations for? I could understand doing one after the join, but why two?
- Finally, what are the two "Compute Scalar" for? When I hovered over them I was expecting it to tell me something along the lines of "This is the
CASEstatement", but they were pretty opaque. How can I tell what the "Compute Scalar"s are doing?
