Re: [HACKERS] Runtime Partition Pruning

From: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
To: Beena Emerson <memissemerson(at)gmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>, Robert Haas <robertmhaas(at)gmail(dot)com>, amul sul <sulamul(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>
Subject: Re: [HACKERS] Runtime Partition Pruning
Date: 2018-01-06 11:03:54
Message-ID: CAKJS1f8gPmRkJkHQ6WbKYS+nDxXT2fKDjcT_xED2k37eWW0pYw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 6 January 2018 at 07:31, Beena Emerson <memissemerson(at)gmail(dot)com> wrote:
> It does not handle change in column order (varattno) in subpartitions.

Thanks for testing and finding that. I completely overlooked applying
translation of the prune qual so that it's compatible with the
sub-partition.

I've fixed this in the attached, but I did so by calling
adjust_appendrel_attrs() from the nodeAppend.c, which did, of course,
mean that the AppendRelInfo needed to be given to the executor. I was
also a bit unsure what exactly I should be doing in primnodes.h, since
I've put PartitionPruneInfo in there, but AppendRelInfo is not. I
stuck a quick declaration of AppendRelInfo in primnode.h with an XXX
comment so we don't forget to think about that again.

In all honesty, this calling planner code from the executor seems like
quite new ground for PostgreSQL, so I'm really not sure if we're
breaking any major rules or not with we've got now. Perhaps the saving
grace here is that we're not teaching the executor how to do anything
smart with these data structures, they're just given to it to pass
back to the planner function at the appropriate moment.

I've also borrowed and simplified your test case to ensure this fix
remains working. I added another level of partitioning with another
partition that has the columns in a different order again. This is to
ensure the translation code translates from the quals of the previous
level up, not the top-level. That's required since the AppendRelInfo
is only translating 1 level at a time.

--
David Rowley http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

Attachment Content-Type Size
runtime_prune_drowley_v6.patch application/octet-stream 106.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2018-01-06 11:33:45 Re: [HACKERS] Removing useless DISTINCT clauses
Previous Message David Rowley 2018-01-06 10:08:10 Re: [HACKERS] Removing useless DISTINCT clauses