X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 27D149DCBC7 for ; Wed, 15 Feb 2006 18:06:57 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 32932-04 for ; Wed, 15 Feb 2006 18:06:58 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from r1.mycybernet.net (r1.mycybernet.net [209.5.206.8]) by postgresql.org (Postfix) with ESMTP id 2DC449DCB31 for ; Wed, 15 Feb 2006 18:06:55 -0400 (AST) Received: from 227-54-222-209.mycybernet.net ([209.222.54.227]:33916 helo=phlogiston.dydns.org) by r1.mycybernet.net with esmtp (Exim 4.50 (FreeBSD)) id 1F9UnZ-000CjA-9X for pgsql-sql@postgresql.org; Wed, 15 Feb 2006 17:06:57 -0500 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id 6225F4040; Wed, 15 Feb 2006 17:06:56 -0500 (EST) Date: Wed, 15 Feb 2006 17:06:56 -0500 From: Andrew Sullivan To: pgsql-sql@postgresql.org Subject: Re: How to force PostgreSQL using an index Message-ID: <20060215220656.GF6562@phlogiston.dyndns.org> References: <1E293D3FF63A3740B10AD5AAD88535D2019091DC@UBIMAIL1.ubisoft.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1E293D3FF63A3740B10AD5AAD88535D2019091DC@UBIMAIL1.ubisoft.org> User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.096 required=5 tests=[AWL=0.096] X-Spam-Score: 0.096 X-Spam-Level: X-Archive-Number: 200602/188 X-Sequence-Number: 24198 On Wed, Feb 15, 2006 at 04:58:54PM -0500, Daniel Caune wrote: > Hi, > > > > Is there a way to force PostgreSQL using an index for a SELECT > statement? I just want to confirm that the index PostgreSQL decides to > use is better than the index I supposed PostgreSQL would use (I already > analyze the table). Your best bet is to do set enable_indexscan=false; and then do the EXPLAIN ANALYSE for your select. You might also find that fiddling with other settings affects the planner's idea of what would be a good plan. The planner is sensitive to what it thinks it knows about your environment. A -- Andrew Sullivan | ajs@crankycanuck.ca If they don't do anything, we don't need their acronym. --Josh Hamilton, on the US FEMA