Re: Make transformAExprIn() return a flattened bool expression directly - Mailing list pgsql-hackers

From ZizhuanLiu X-MAN
Subject Re: Make transformAExprIn() return a flattened bool expression directly
Date
Msg-id tencent_E9754A23203C449B2BEDE9C4D83785651A06@qq.com
Whole thread
In response to Re: Make transformAExprIn() return a flattened bool expression directly  ("cca5507" <cca5507@qq.com>)
List pgsql-hackers
>From: cca5507 <cca5507@qq.com>
>Date: 2026-04-30 18:16
>To: Chao Li <li.evan.chao@gmail.com>
>Cc: pgsql-hackers <pgsql-hackers@lists.postgresql.org>
>Subject: Re: Make transformAExprIn() return a flattened bool expression directly
>
>
>      Hi Chao,
>
>Thanks for your comments. I have created a CF entry:
>
>https://commitfest.postgresql.org/patch/6723/
>
>--
>Regards,
>ChangAo Chen


Hi, ChangAo, Chao, Hackers,
``
Thanks a lot for the suggestion to avoid nested structures in transformAExprIn(). 
I also agree that handling this kind of simplification during parsing is cleaner and more appropriate, 
even though the planner can achieve a similar effect later via preprocess_qual_conditions().
``
I further refined and polished this implementation based on v1 patch. I intentionally keep 
all the core logic inside the existing foreach(l, rexprs) loop. This way better preserves the integrity of 
the function, minimizes code intrusion, and makes the overall logic easier to follow. I put careful thought 
into this implementation, and more details are documented in the code comments.
``
I have updated the patch accordingly and prepared corresponding test cases to cover the modified scenarios, 
ensuring the correctness and stability of the optimization. 
``
Any feedback and further suggestions are highly appreciated.

create table t1(id int);
create table t2(id int);
create table t3(id int);

explain select t1.* from t1, t2, t3 where t1.id in (1);
explain select t1.* from t1, t2, t3 where t1.id in (1,1);

explain select t1.* from t1, t2, t3 where t1.id in (t2.id);
explain select t1.* from t1, t2, t3 where t1.id in (t2.id, t2.id);

explain select t1.* from t1, t2, t3 where t1.id in (1, t2.id, t2.id, 1);

explain select t1.* from t1, t2, t3 where (t1.id,t2.id) in ((1, 11));
explain select t1.* from t1, t2, t3 where (t1.id,t2.id) in ((1,11),(1,11));

explain select t1.* from t1, t2, t3 where (t1.id,t2.id) in ((t2.id, t2.id));
explain select t1.* from t1, t2, t3 where (t1.id,t2.id) in ((t2.id, t2.id),(t2.id, t2.id));
explain select t1.* from t1, t2, t3 where (t1.id,t2.id) in ((1,11), (t2.id, t2.id),(t2.id, t2.id), (1,11));

Thanks,
--
ZizhuanLiu (X-MAN) 
44973863@qq.com
Attachment

pgsql-hackers by date:

Previous
From: Tender Wang
Date:
Subject: Re: Eager aggregation, take 3
Next
From: Amit Kapila
Date:
Subject: Re: Proposal: Conflict log history table for Logical Replication