X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BC0FF52894 for ; Mon, 1 Aug 2005 19:37:27 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 91710-06 for ; Mon, 1 Aug 2005 22:37:21 +0000 (GMT) Received: from mail.nordicbet.com (mail.nordicbet.com [193.69.167.130]) by svr1.postgresql.org (Postfix) with ESMTP id BE84652B4E for ; Mon, 1 Aug 2005 19:37:16 -0300 (ADT) Received: from [84.48.51.94] (helo=tobias.nordicbet.invalid) (Authenticated Sender=tobias@nordicbet.com) by mail.nordicbet.com with esmtpa (Exim 4.50 #1 (Debian)) id 1DzisS-0003iy-QW; Tue, 02 Aug 2005 00:35:29 +0200 Received: by tobias.nordicbet.invalid (Postfix, from userid 500) id AE30FE003B; Tue, 2 Aug 2005 00:37:08 +0200 (CEST) Date: Tue, 2 Aug 2005 00:37:08 +0200 From: Tobias Brox To: meetesh.karia@alumni.duke.edu Cc: pgsql-performance@postgresql.org Subject: Re: Planner incorrectly choosing seq scan over index scan Message-ID: <20050801223708.GE17649@tobias.lan> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Group Nordicbet User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200508/13 X-Sequence-Number: 13760 [Meetesh Karia - Tue at 12:19:27AM +0200] > We're using 8.0.3 and we're seeing a problem where the planner is choosing a > seq scan and hash join over an index scan. If I set enable_hashjoin to off, > then I get the plan I'm expecting and the query runs a lot faster. I've also > tried lowering the random page cost (even to 1) but the planner still > chooses to use the hash join. Have you tried increasing the statistics collection? -- Tobias Brox, +47-91700050 Nordicbet, IT dept