Re: why partition pruning doesn't work?

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Rowley <david.rowley@2ndquadrant.com>
Cc: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>, Dmitry Dolgov <9erthalion6@gmail.com>, Jeff Janes <jeff.janes@gmail.com>, Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>, Pavel Stehule <pavel.stehule@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2018-06-11T14:26:32Z
Lists: pgsql-hackers
David Rowley <david.rowley@2ndquadrant.com> writes:
> On 11 June 2018 at 10:49, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> * The business with ExecFindInitialMatchingSubPlans remapping the
>> subplan indexes seems very dubious to me.  Surely, that is adding
>> way more complexity and fragility than it's worth.

> I think having the ability to prune during executor initialisation is
> enormously important. I think without it, this patch is less than half
> as useful.

Sure.

> However, if you didn't mean removing the executor
> initialise pruning, and just not remapping the arrays, then I'm not
> sure how we'd do that.  I'd previously tried having NULL subnodes in
> the Append and I thought it required too much hacking work in
> explain.c, so I decided to just collapse the array instead and do what
> was required to make it work after having removed the unneeded
> subplans. Did you have another idea on how to do this?

No, that was pretty much exactly what I was envisioning.  I have
not looked at the consequences for explain.c but it seemed like
it couldn't be all that bad; and to my mind the remapping business
in the partition code is pretty bad.  "It's all in one file" is not
a suitable justification for unintelligible, overcomplex code.

			regards, tom lane


Commits

  1. Fix up run-time partition pruning's use of relcache's partition data.

  2. Fix access to just-closed relcache entry.

  3. Improve ExecFindInitialMatchingSubPlans's subplan renumbering logic.

  4. Improve commentary about run-time partition pruning data structures.

  5. Fix run-time partition pruning code to handle NULL values properly.

  6. Assorted cosmetic cleanup of run-time-partition-pruning code.

  7. Relocate partition pruning structs to a saner place.

  8. Improve run-time partition pruning to handle any stable expression.

  9. Support partition pruning at execution time