Thread

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

    ZizhuanLiu X-MAN <44973863@qq.com> — 2026-05-31T11:39:06Z

    &gt;From: cca5507 <cca5507@qq.com&gt;
    &gt;Date: 2026-04-30 18:16
    &gt;To: Chao Li <li.evan.chao@gmail.com&gt;
    &gt;Cc: pgsql-hackers <pgsql-hackers@lists.postgresql.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@qq.com