Re: Missing MaterialPath support in reparameterize_path_by_child

2022-12-06 Thread Tom Lane
Ashutosh Bapat writes: > On Mon, Dec 5, 2022 at 8:13 PM Tom Lane wrote: >> I don't especially like "rel->nparts = 0" as a way of disabling >> partitionwise join ... > ... If we can not generate AppendPath for a > join relation, it means there is no way to compute child join > relations and thus

Re: Missing MaterialPath support in reparameterize_path_by_child

2022-12-06 Thread Ashutosh Bapat
On Mon, Dec 5, 2022 at 8:13 PM Tom Lane wrote: > > Ashutosh Bapat writes: > > partition-wise join should be willing to fallback to non-partitionwise > > join in such a case. After spending a few minutes with the code, I > > think generate_partitionwise_join_paths() should not call > >

Re: Missing MaterialPath support in reparameterize_path_by_child

2022-12-05 Thread Tom Lane
Ashutosh Bapat writes: > partition-wise join should be willing to fallback to non-partitionwise > join in such a case. After spending a few minutes with the code, I > think generate_partitionwise_join_paths() should not call > set_cheapest() is the pathlist of the child is NULL and should just >

Re: Missing MaterialPath support in reparameterize_path_by_child

2022-12-05 Thread Ashutosh Bapat
On Fri, Dec 2, 2022 at 9:13 PM Tom Lane wrote: > > Ashutosh Bapat writes: > > On Fri, Dec 2, 2022 at 8:25 AM Tom Lane wrote: > >> Unfortunately, I don't have an example that produces such a > >> failure against HEAD. It seems certain to me that such cases > >> exist, though, so I'd like to

Re: Missing MaterialPath support in reparameterize_path_by_child

2022-12-02 Thread Tom Lane
Ashutosh Bapat writes: > On Fri, Dec 2, 2022 at 8:25 AM Tom Lane wrote: >> Unfortunately, I don't have an example that produces such a >> failure against HEAD. It seems certain to me that such cases >> exist, though, so I'd like to apply and back-patch the attached. > From this comment, that I

Re: Missing MaterialPath support in reparameterize_path_by_child

2022-12-02 Thread Richard Guo
On Fri, Dec 2, 2022 at 8:49 PM Richard Guo wrote: > BTW, the code changes I'm using: > > --- a/src/backend/optimizer/util/pathnode.c > +++ b/src/backend/optimizer/util/pathnode.c > @@ -3979,6 +3979,17 @@ reparameterize_path(PlannerInfo *root, Path *path, >

Re: Missing MaterialPath support in reparameterize_path_by_child

2022-12-02 Thread Richard Guo
On Fri, Dec 2, 2022 at 7:21 PM Ashutosh Bapat wrote: > > I'm suspicious now that reparameterize_path() should be > > extended likewise, but I don't really have any hard > > evidence for that. > > I think we need it there since the scope of paths under appendrel has > certainly expanded a lot

Re: Missing MaterialPath support in reparameterize_path_by_child

2022-12-02 Thread Ashutosh Bapat
Hi Tom, On Fri, Dec 2, 2022 at 8:25 AM Tom Lane wrote: > > Whilst fooling with my outer-join-aware-Vars patch, I tripped > across a multi-way join query that failed with > ERROR: could not devise a query plan for the given query > when enable_partitionwise_join is on. > > I traced that to the

Re: Missing MaterialPath support in reparameterize_path_by_child

2022-12-01 Thread Richard Guo
On Fri, Dec 2, 2022 at 10:55 AM Tom Lane wrote: > I traced that to the fact that reparameterize_path_by_child() > omits support for MaterialPath, so that if the only surviving > path(s) for a child join include materialization steps, we'll > fail outright to produce a plan for the parent join.

Missing MaterialPath support in reparameterize_path_by_child

2022-12-01 Thread Tom Lane
Whilst fooling with my outer-join-aware-Vars patch, I tripped across a multi-way join query that failed with ERROR: could not devise a query plan for the given query when enable_partitionwise_join is on. I traced that to the fact that reparameterize_path_by_child() omits support for