In Tajo, sort operator is similar to merge sort, and it works in a distributed manner. The first sort phase sorts each fragment in local machine, the intermediate data are shuffled in range partition, and then the second sort phase in each node sorts the range-partitioned data.
However, the second sort phase reads all shuffled data via one scanner. It misses the opportunity to exploit already-sorted data. This patch improves the second sort phase to merge directly multiple already-sorted intermediate data sets. It significantly reduces the response time of sort queries.
I carried out some simple benchmark with the following query on TPC-H 100GB data sets: