Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 5EE0C79A0B6 for ; Wed, 17 Mar 2010 19:04:38 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 98053-06 for ; Wed, 17 Mar 2010 22:04:21 +0000 (UTC) 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 8366B79A0B8 for ; Wed, 17 Mar 2010 19:04:27 -0300 (ADT) 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 o2HM4QYm027002; Wed, 17 Mar 2010 18:04:26 -0400 (EDT) To: Christian Brink cc: pgsql-performance@postgresql.org Subject: Re: Forcing index scan on query produces 16x faster In-reply-to: <4BA148CF.5080701@r-stream.com> References: <4BA148CF.5080701@r-stream.com> Comments: In-reply-to Christian Brink message dated "Wed, 17 Mar 2010 17:25:35 -0400" Date: Wed, 17 Mar 2010 18:04:25 -0400 Message-ID: <27001.1268863465@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.46 tagged_above=-10 required=5 tests=AWL=0.139, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201003/216 X-Sequence-Number: 38041 Christian Brink writes: > Is there a way to rewrite or hint the planner to get me the better plan > without resorting to 'enable_seqscan' manipulation (or am I missing > something)? I think your problem is here: > PostgreSQL 8.0.3 on i386-redhat-linux-gnu, compiled by GCC > i386-redhat-linux-gcc (GCC) 4.0.0 20050505 (Red Hat 4.0.0-4) Recent versions are significantly smarter about grouping operations than that dinosaur. (Even if you must stay on 8.0.x, you should at least be running 8.0.something-recent; what you have is full of security and data-loss risks. 8.0.24 was released this week.) regards, tom lane