Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i4jcH-0003zd-Pp for pgsql-bugs@arkaria.postgresql.org; Mon, 02 Sep 2019 10:31:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i4jcG-00088I-D3 for pgsql-bugs@arkaria.postgresql.org; Mon, 02 Sep 2019 10:31:20 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i4idg-0004Fu-1d for pgsql-bugs@lists.postgresql.org; Mon, 02 Sep 2019 09:28:44 +0000 Received: from mail.verfriemelt.org ([138.201.40.18]) by makus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1i4idY-0000Jf-Up for pgsql-bugs@lists.postgresql.org; Mon, 02 Sep 2019 09:28:42 +0000 X-Spam-Status: No, hits=0.0 required=4.0 tests=BAYES_00: -1.665,HTML_MESSAGE: 0.001,TOTAL_SCORE: -1.664,autolearn=ham X-Spam-Level: Received: from localhost ([127.0.0.1]) by mail.verfriemelt.org; Mon, 2 Sep 2019 11:28:07 +0200 To: "Tom Lane" Cc: pgsql-bugs@lists.postgresql.org From: easteregg@verfriemelt.org Subject: Re: BUG #15984: order of where in() query affects query planer In-Reply-To: 7528.1567117005@sss.pgh.pa.us Message-ID: <20190902092807.0e0770b0@mail.verfriemelt.org> Date: Mon, 02 Sep 2019 11:28:07 +0200 X-User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3759.4 Safari/537.36 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="-----------4ab27f8c6d3a14f6f7f44d25b226e20a" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. -------------4ab27f8c6d3a14f6f7f44d25b226e20a Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable i have created another example for you, were i get consistent results af= ter the analyse with the different plans: create table test( a int, b int, c int ); insert into test select random()*100, random()*10, random()*5 FROM generate=5Fseries(1,10= 00000); create index "full" on test( a, c ); create index "partial" on test( a, c ) where ( a in ( 3,4,5,6,7,8,9,10 )= and b in ( 2,3 ) ); analyse test; explain analyse select * from test where a in ( 3,4,5,6,7,8,9,10 ) and b= in ( 2,3 ); explain analyse select * from test where a in ( 3,4,5,6,7,8,10,9 ) and b= in ( 2,3 ); do i have wrong expections from theryplanner, that those are in fact two= different paths to take=3F currently i work around this issue by sortin= g the elements for the in statements, but i think that must be the wrong= path. with kind regards, richard -------------4ab27f8c6d3a14f6f7f44d25b226e20a Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable i have created another example for you, were i get consistent result= s after the analyse with the different plans:

crea= te table test( a int, b int, c int );
insert into test
s= elect random()*100, random()*10, random()*5 FROM generate=5Fseries(1,100= 0000);
create index "full" o= n test( a, c );
create index= "partial" on test( a, c ) where ( a in ( 3,4,5,6,7,8,9,10 ) and b in ( = 2,3 ) );
analyse test;

explain analyse select * from test where a in ( 3,4,5,6,= 7,8,9,10 ) and b in ( 2,3 );

explain analyse select = * from test where a in ( 3,4,5,6,7,8,10,9&= nbsp;) and b in ( 2,3 );

=
do i have wrong expections from theryplan= ner, that those are in fact two different paths to take=3F currently i w= ork around this issue by sorting the elements for the in statements, but= i think that must be the wrong path.

with kind reg= ards, richard
-------------4ab27f8c6d3a14f6f7f44d25b226e20a--