On Fri, Sep 22, 2017 at 4:23 PM, Julien Rouhaud <rjuju...@gmail.com> wrote: > That was one of the first question we had with the initial POC. The > reason is that this "sorted append" is not using a merge algorithm but > just appending partitions in the right order, so it looked like we > could either create a new SortedAppend node, or use current Append > node and allow it to return sorted data. We chose the 2nd solution, > and ended up with a lot of duplicated code (all the code for the > ordering), so we tried to have Append and MergeAppend share this code. > I'm not at all satisfied with current shape, but I'm still not sure on > what node to use for this. Do you have any idea on this?
During planning, *every* node has a list of pathkeys associated with it which represent the presumed output ordering. You can support ordered append paths without changing any data structures at all; it's just a matter of putting pathkeys into an AppendPath. The reason why MergeAppend has extra stuff in the node (numCols, sortColIdx, etc.) is so that it can actually perform the sort at runtime. But this feature requires no runtime support -- that's kinda the point -- so there's no need for it to carry that information, or to add any new nodes. At least, IIUC. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (email@example.com) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers