Ashutosh Bapat <ashutosh.bapat....@gmail.com> 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 > wind up and avoid adding any path.
We clearly need to not call set_cheapest(), but that's not sufficient; we still fail at higher levels, as you'll see if you try the example Richard found. I ended up making fe12f2f8f to fix this. I don't especially like "rel->nparts = 0" as a way of disabling partitionwise join; ISTM it'd be clearer and more flexible to reset consider_partitionwise_join instead of destroying the data structure. But that's the way it's being done elsewhere, and I didn't want to tamper with it in a bug fix. I see various assertions about parent and child consider_partitionwise_join flags being equal, which we might have to revisit if we try to make it work that way. regards, tom lane