I have a table like the following
sales int
period_key int
store_key intproduct_key int
It is partitioned on period_key which is like 20110806, etc, every day is a partition. The query is
select product_key,store_key ,max(sales) from tab group by product_key,store_key where period_key between 20110806 and 20110816
The table also has a clustered index on (product_key,store_key,period_key). The sql plan is to parallel read each partition, and then sort and output, since the sort cost takes 95% of the total cost, it's very costly. But since we has a clustered index on it, I am wondering whether we could remove the costly sort like this:
each thread read on partition, the master thread then consume the data from each thread, and use the merge sort to output. This kind of sort should be super fast as the slave thread already has the data sorted.