Re: [Proposal] Make the optimiser aware of partitions ordering

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Julien Rouhaud <rjuju123(at)gmail(dot)com>
Cc: Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [Proposal] Make the optimiser aware of partitions ordering
Date: 2017-09-22 21:09:09
Message-ID: CA+TgmoYLUWMF+ydZuAnLrR1Fc5VDxPOZfjiOmuf4wpkZ3_vdLw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Sep 22, 2017 at 4:23 PM, Julien Rouhaud <rjuju123(at)gmail(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2017-09-22 21:46:08 Re: [BUGS] BUG #14825: enum type: unsafe use?
Previous Message Tom Lane 2017-09-22 21:09:03 Rethinking autovacuum.c memory handling