PlaceholderVars and join removal with appendrel parents - Mailing list pgsql-hackers

From Arne Roland
Subject PlaceholderVars and join removal with appendrel parents
Date
Msg-id 27a44087-3d65-473e-8d88-7c12228e0d7e@malkut.net
Whole thread
Responses Re: PlaceholderVars and join removal with appendrel parents
List pgsql-hackers
Hi Richard,

thank you for your great work with the optimizer!

I just stumbled and by accident landed on your commit 9a60f295bcb (and 
then looked up the discussion 
https://www.postgresql.org/message-id/flat/CALzhyqwryL2QywgO03VQr_237Sq3MEVgTTT2_A9G3nGT5-SRZg%40mail.gmail.com). 
I am under the impression we need to extend the same fix for or clauses 
descending into the orclause sub-RestrictInfos.

This is the simplified minimal test case, that is failing for me:

CREATE TABLE a (id int PRIMARY KEY, b_id int);
CREATE TABLE uniq (id int PRIMARY KEY);
CREATE TABLE parted_b (id int PRIMARY KEY) PARTITION BY RANGE (id);
CREATE TABLE parted_b1 PARTITION OF parted_b FOR VALUES FROM (0) TO (10);

SELECT 1 FROM a, (SELECT t1.id FROM parted_b t1 LEFT JOIN uniq t2 ON 
t1.id = t2.id) s
WHERE (s.id = 1 AND a.id = 2) OR (s.id = 3 AND a.id = 4) GROUP BY ();

My idea would be to put a bitmapset into remove_rel_from_query with the 
seen ones and recurse removing it from the rinfo. I attached a sketch of 
my idea. But maybe our have a better one.

Regards
Arne

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: sequencesync worker race with REFRESH SEQUENCES
Next
From: Jim Jones
Date:
Subject: Re: Proposal: INSERT ... BY NAME