Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id F171A9FA6AF for ; Sat, 27 Jan 2007 03:26:21 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 01838-10 for ; Sat, 27 Jan 2007 03:26:10 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mxfep01.bredband.com (mxfep01.bredband.com [195.54.107.70]) by postgresql.org (Postfix) with ESMTP id BD2089FA371 for ; Sat, 27 Jan 2007 03:26:16 -0400 (AST) Received: from ironport.bredband.com ([195.54.107.82] [195.54.107.82]) by mxfep01.bredband.com with ESMTP id <20070127072615.FCHT3634.mxfep01.bredband.com@ironport.bredband.com> for ; Sat, 27 Jan 2007 08:26:15 +0100 Received: from ua-83-227-204-174.cust.bredbandsbolaget.se (HELO zigo.dhs.org) ([83.227.204.174]) by ironport.bredband.com with ESMTP; 27 Jan 2007 08:26:15 +0100 Received: from [192.168.0.3] (cosmo.zigo.dhs.org [192.168.0.3]) by zigo.dhs.org (Postfix) with ESMTP id E23EE8640; Sat, 27 Jan 2007 08:26:13 +0100 (CET) Message-ID: <45BAFE95.8060409@zigo.dhs.org> Date: Sat, 27 Jan 2007 08:26:13 +0100 From: Dennis Bjorklund User-Agent: Thunderbird 1.5.0.9 (X11/20061206) MIME-Version: 1.0 To: Carlos Moreno Cc: pgsql-performance@postgresql.org Subject: Re: Seqscan/Indexscan still a known issue? References: <45BAB682.6060709@mochima.com> In-Reply-To: <45BAB682.6060709@mochima.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200701/378 X-Sequence-Number: 22979 Carlos Moreno skrev: > When I force it via "set enable_seqscan to off", the index scan > takes about 0.1 msec (as reported by explain analyze), whereas > > For the time being, I'm using an explicit "enable_seqscan off" > in the client code, before executing the select. But I wonder: > Is this still an issue, or has it been solved in the latest > version? For most queries it has never been an issue. Every once in a while there is a query that the planner makes a non-optimal plan for, but it's not that common. In general the optimizer has improved with every new version of pg. Almost everyone I've talked to that has upgraded has got a faster database tham before. It was like that for 7.4->8.0, for 8.0->8.1 and for 8.1->8.2. So in your case going from 7.4->8.2 is most likely going to give a speedup (especially if you have some queries that isn't just simple primary key lookups). In your case it's hard to give any advice since you didn't share the EXPLAIN ANALYZE output with us. I'm pretty sure it's possible to tune pg so it makes the right choice even for this query of yours but without the EXPLAIN ANALYZE output we would just be guessing anyway. If you want to share it then it might be helpful to show the plan both with and without seqscan enabled. How often do you run VACUUM ANALYZE; on the database? /Dennis