Execution plan for COMPUTE BY
How does the query processor execute COMPUTE BY?


It is a hard-coded sequence of operations at the top of the execution tree. There is a simple stream accumulation (hence the ordering requirement), some logic to detect the start of a new group, a little computation and data value copying, and direct calls to construct the alternate TDS result sets per group. Some example call stacks from a query using COMPUTE BY are shown below:








  and how can I obtain an accurate execution plan?


You can't, because COMPUTE BY is not implemented in the same way as other plan operations. The replacement ROLLUP support does use the regular execution framework, automatically providing showplan information. An additional benefit of ROLLUP is that it does not use alternate TDS result sets, providing better client compatibility. In short, no one will miss COMPUTE.