Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T1kYe-0003A2-Ae for pgsql-performance@postgresql.org; Wed, 15 Aug 2012 20:51:16 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T1kYc-0001t5-Rp for pgsql-performance@postgresql.org; Wed, 15 Aug 2012 20:51:16 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id q7FKpDVa016269; Wed, 15 Aug 2012 16:51:13 -0400 (EDT) From: Tom Lane To: Christophe Pettus cc: pgsql-performance@postgresql.org Subject: Re: 7k records into Sort node, 4.5m out? In-reply-to: <623F2FF3-B79D-419A-929A-41C707DD5EA3@thebuild.com> References: <32B51AEA-E940-40CF-BA54-C7D4E3E1F0D7@thebuild.com> <10304.1344910305@sss.pgh.pa.us> <623F2FF3-B79D-419A-929A-41C707DD5EA3@thebuild.com> Comments: In-reply-to Christophe Pettus message dated "Wed, 15 Aug 2012 12:13:19 -0700" Date: Wed, 15 Aug 2012 16:51:12 -0400 Message-ID: <16268.1345063872@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201208/86 X-Sequence-Number: 47624 Christophe Pettus writes: > On Aug 13, 2012, at 7:11 PM, Tom Lane wrote: >> The whole thing looks a bit weird to me --- why did it not use a >> nestloop join with inner indexscan on charlie? With 7000 rows on the >> other side, the estimated cost for that shouldn't have been more than >> about 30000 ... > Here's the same query with set enable_megejoin = off. All of the other query tuning parameters are default. > http://explain.depesz.com/s/dqO Maybe you had better show us the actual query, and the table/index definitions. Because it's sure making odd choices here. This seems like the wrong join order altogether ... regards, tom lane