Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 5F75C64FD30 for ; Sun, 7 Dec 2008 22:02:16 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 10239-03 for ; Sun, 7 Dec 2008 22:02:13 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 6805C64FCDF for ; Sun, 7 Dec 2008 22:02:13 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id mB822Bcl005093; Sun, 7 Dec 2008 21:02:11 -0500 (EST) To: glynastill@yahoo.co.uk cc: pgsql-general@postgresql.org Subject: Re: Planner picking topsey turvey plan? In-reply-to: <167634.59714.qm@web23608.mail.ird.yahoo.com> References: <167634.59714.qm@web23608.mail.ird.yahoo.com> Comments: In-reply-to Glyn Astill message dated "Fri, 05 Dec 2008 14:23:30 +0000" Date: Sun, 07 Dec 2008 21:02:11 -0500 Message-ID: <5092.1228701731@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200812/290 X-Sequence-Number: 141422 Glyn Astill writes: > Does anyone know how I can change what I'm doing to get pgsql to pick a better plan? You've provided no evidence that this is a bad plan. In particular, the plan you seem to think would be better would involve an estimated 153 iterations of the cost-15071 hash aggregation, which simple arithmetic shows is more expensive than the plan it did choose. regards, tom lane