Re: Make transformAExprIn() return a flattened bool expression directly

From: ZizhuanLiu X-MAN <44973863(at)qq(dot)com>
To: cca5507 <cca5507(at)qq(dot)com>, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: 我自己的邮箱 <44973863(at)qq(dot)com>
Subject: Re: Make transformAExprIn() return a flattened bool expression directly
Date: 2026-05-31 11:39:06
Message-ID: tencent_E9754A23203C449B2BEDE9C4D83785651A06@qq.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

&gt;From: cca5507 <cca5507(at)qq(dot)com&gt;
&gt;Date: 2026-04-30 18:16
&gt;To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com&gt;
&gt;Cc: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org&gt;
&gt;Subject: Re: Make transformAExprIn() return a flattened bool expression directly
&gt;
&gt;
&gt; &nbsp; &nbsp; &nbsp;Hi Chao,
&gt;
&gt;Thanks for your comments. I have created a CF entry:
&gt;
&gt;https://commitfest.postgresql.org/patch/6723/
&gt;
&gt;--
&gt;Regards,
&gt;ChangAo Chen

Hi, ChangAo, Chao, Hackers,
``
Thanks a lot for the suggestion to avoid nested structures in transformAExprIn().&nbsp;
I also agree that handling this kind of simplification during parsing is cleaner and more appropriate,&nbsp;
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&nbsp;
all the core logic inside the existing foreach(l, rexprs) loop. This way better preserves the integrity of&nbsp;
the function, minimizes code intrusion, and makes the overall logic easier to follow. I put careful thought&nbsp;
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,&nbsp;
ensuring the correctness and stability of the optimization.&nbsp;
``
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&nbsp;(X-MAN)&nbsp;
44973863(at)qq(dot)com

Attachment Content-Type Size
v2-0001-Make-transformAExprIn-return-a-flattened-bool-exp.patch application/octet-stream 1.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2026-05-31 11:54:08 Re: Proposal: Conflict log history table for Logical Replication
Previous Message Tender Wang 2026-05-31 11:28:37 Re: Eager aggregation, take 3