Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 7EEB89FB404 for ; Mon, 26 Mar 2007 12:38:34 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 14034-05 for ; Mon, 26 Mar 2007 12:38:18 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from globalrelay.com (mail1.globalrelay.com [204.92.49.200]) by postgresql.org (Postfix) with ESMTP id 993569FA4D1 for ; Mon, 26 Mar 2007 12:38:18 -0300 (ADT) X-Virus-Scanned: Scanned by GRC-AntiVirus Gateway X-GR-Acctd: YES Received: from [63.226.156.118] (HELO DaveEMachine) by globalrelay.com (CommuniGate Pro SMTP 4.2.3) with ESMTP id 133636427; Mon, 26 Mar 2007 08:38:13 -0700 From: "Dave Dutcher" To: "'Gauri Kanekar'" Cc: Subject: Re: Nested Loop Date: Mon, 26 Mar 2007 10:38:12 -0500 Message-ID: <004101c76fbc$c439b700$2e00a8c0@tridecap.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.6822 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 Thread-Index: AcdvuEcMLyIsGqmySDWh4+55xiq5bgAA39Xw In-Reply-To: <7e4ba9550703260803l16b86ef0w42182ef762837db8@mail.gmail.com> Importance: Normal X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200703/397 X-Sequence-Number: 23802 -----Original Message----- >From: pgsql-performance-owner@postgresql.org On Behalf Of Gauri Kanekar >Subject: Re: [PERFORM] Nested Loop > >join_collapse_limit =3D 1 # JOINs=20 Is there a reason you have this set to 1? Postgres can't consider = multiple join orders when you do that. I would try setting that back to the = default and seeing if this query is any faster. Other than that it looked like the problems with the query might be bad estimates of rows. One is that postgres expects there to be 1 matching = row from rd when there are actually 30. You might try increasing the = statistics targets on rd.sd and rd.sdt, reanalyzing, and seeing if that helps. = Also postgres expects the join of rd and rm to return about 27205 rows when = it actually returns 10 million. I'm not sure what you can do about that. Maybe if Postgres gets a better estimate for rd it would then estimate = the join better. Dave