Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 1B43113C6999 for ; Fri, 4 May 2012 11:40:57 -0300 (ADT) Received: from gwmta.wicourts.gov ([165.219.244.99] helo=gw.wicourts.gov) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SQJgl-00076H-1R for pgsql-performance@postgresql.org; Fri, 04 May 2012 14:40:56 +0000 Received: from Courts-MTA by gw.wicourts.gov with Novell_GroupWise; Fri, 04 May 2012 09:40:42 -0500 Message-Id: <4FA3A410020000250004787C@gw.wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 8.0.2 Date: Fri, 04 May 2012 09:40:32 -0500 From: "Kevin Grittner" To: "Dan Fairs" , Subject: Re: Unexpected sequence scan References: <07F01B2A-648A-4BA7-B056-EC4EA2FFE0D0@gmail.com> In-Reply-To: <07F01B2A-648A-4BA7-B056-EC4EA2FFE0D0@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Pg-Spam-Score: -4.2 (----) X-Archive-Number: 201205/47 X-Sequence-Number: 46871 Dan Fairs wrote: > I have a query which is running slowly, and the query plan shows > an unexpected sequence scan where I'd have expected the planner to > use an index. Looking at the actual row counts compared to run time, it appears that the active portion of your data set is heavily cached. In such an environment, I would add these lines to postgresql.conf, to better model costs: seq_page_cost = 0.1 random_page_cost = 0.1 # or maybe slightly higher cpu_tuple_cost = 0.03 -Kevin