Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TED8t-0001Sl-BQ for pgsql-bugs@postgresql.org; Wed, 19 Sep 2012 05:48:11 +0000 Received: from mahout.postgresql.org ([98.129.198.123]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TED8s-0001U7-EV for pgsql-bugs@postgresql.org; Wed, 19 Sep 2012 05:48:10 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TED8r-0005Lb-Do for pgsql-bugs@postgresql.org; Wed, 19 Sep 2012 05:48:10 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1TED8q-00047D-Va for pgsql-bugs@postgresql.org; Wed, 19 Sep 2012 05:48:08 +0000 Date: Wed, 19 Sep 2012 05:48:08 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #7556: "select not in sub query" plan very poor vs "not exists" To: pgsql-bugs@postgresql.org From: l1t@tom.com X-Pg-Spam-Score: -2.5 (--) X-Archive-Number: 201209/213 X-Sequence-Number: 34207 The following bug has been logged on the website: Bug reference: 7556 Logged by: lt Email address: l1t@tom.com PostgreSQL version: 9.2.0 Operating system: windows xp Description: = test=3D# create table sli_test (id int primary key,info varchar(20)); test=3D# insert into sli_test select generate_series(1,1000000),'digoal'||generate_series(1,1000000); test=3D# analyze verbose sli_test; test=3D# create table sli_test2 (id int not null,info varchar(20)); test=3D# insert into sli_test2 select generate_series(1,1000000),'dbase'||generate_series(1,1000000); test=3D# analyze verbose sli_test2; test=3D# explain select max(a.info)from sli_test a where a.id not in(select b.id from sli_test2 b where b.id<50000); QUERY PLAN ---------------------------------------------------------------------------= ------------ Aggregate (cost=3D9241443774.00..9241443774.01 rows=3D1 width=3D12)