Re: Partition-wise join for join between (declaratively) partitioned tables

From: Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>
To: Rafia Sabih <rafia(dot)sabih(at)enterprisedb(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Rajkumar Raghuwanshi <rajkumar(dot)raghuwanshi(at)enterprisedb(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Partition-wise join for join between (declaratively) partitioned tables
Date: 2017-03-22 09:49:57
Message-ID: CAFjFpRcPutbr4nVAsrY-5q=wCFrNK25_3MNhHgyYYM0yeOoj=Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox
Thread:
Lists: pgsql-hackers

>>>
> In an attempt to test the geqo side of this patch, I reduced
> geqo_threshold to 6 and set enable_partitionwise_join to to true and
> tried following query, which crashed,
>
> explain select * from prt, prt2, prt3, prt32, prt4, prt42 where prt.a
> = prt2.b and prt3.a = prt32.b and prt4.a = prt42.b and prt2.a > 1000
> order by prt.a desc;
>
> Stack-trace for the crash is as follows,
>
Nice catch. When reparameterize_path_by_child() may be running in a
temporary memory context while running in GEQO mode. It may add a new
PPI to base relation all in the temporary context. In the next GEQO
cycle, the ppilist will be clobbered since the temporary context is
reset for each geqo cycle. The fix is to allocate PPI in the same
memory context as the RelOptInfo similar to mark_dummy_rel().

I also found another problem. In geqo, we never call
generate_partition_wise_join_paths() which set cheapest paths for each
child-join. Because of this cheapest_*_paths are never set for those
rels, thus segfaulting in functions like sort_inner_and_outer() which
use those.

Here's patch fixing both the issues. Please let me know if it fixes
the issues you are seeing.
--
Best Wishes,
Ashutosh Bapat
EnterpriseDB Corporation
The Postgres Database Company

Attachment Content-Type Size
geqo_fix.patch application/octet-stream 2.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Sharma 2017-03-22 10:09:32 Re: segfault in hot standby for hash indexes
Previous Message Beena Emerson 2017-03-22 09:44:02 Re: increasing the default WAL segment size