[ bringing this discussion back to the original thread ] David Rowley <david.row...@2ndquadrant.com> writes: > The attached patch removes the Assert, but I think it should be > probably be done as part of [1]'s patch since that's also adding the > code to handle subplans for tables that don't belong in the partition > hierarchy.
Over in that thread, we had David Rowley <david.row...@2ndquadrant.com> writes: > On 2 August 2018 at 11:48, Tom Lane <t...@sss.pgh.pa.us> wrote: >> I didn't include this change because (a) it's late, (b) no test >> case was included, and (c) I don't entirely believe it anyway. >> How would a rel be both leaf and nonleaf? Isn't this indicative >> of a problem somewhere upstream in the planner? > It's probably best discussed on the other thread, but it seems to be > by design in accumulate_append_subpath(). Parallel Append nodes don't > get flattened if they contain a mix of parallel aware and non-parallel > aware subplans. Yeah, looking at the explain posted upthread, the issue is specifically that some of the child paths might be for Gathers over subsets of the partitioning hierarchy. It's not real clear to me whether such a subset would necessarily correspond to a subtree of the hierarchy, but if it does, you'd want to be able to apply run-time pruning at the parent Append, in hopes of not having to execute the Gather at all. Separately from that, if you do execute the Gather, applying runtime pruning within its child Append is also a good thing. So what's unclear to me is whether removing that Assert is sufficient to make all of that work nicely. I'm concerned in particular that the planner might get confused about which pruning tests to apply at each level. (EXPLAIN isn't a very adequate tool for testing this, since it fails to show anything about what pruning tests are attached to an Append. I wonder if we need to create something that does show that.) I think it'd be a real good idea to have a test case to exercise this. Jaime's presented test case is too expensive to consider as a regression test, but I bet that a skinnied-down version could be made to work once you'd set all the parallelization parameters to liberal values, like in select_parallel.sql. regards, tom lane