Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id C4FC5650DBC for ; Sun, 29 Jun 2008 19:10:55 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 73391-08 for ; Sun, 29 Jun 2008 19:10:49 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from wizmail.org (wizmail.org [217.146.104.199]) by postgresql.org (Postfix) with ESMTP id 0434A650CF5 for ; Sun, 29 Jun 2008 19:10:52 -0300 (ADT) Received: from ebony.jgh.adsl.wizards.co.uk ([217.146.123.59]) (from_AS 16353) by wizmail.org with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.67) id 1KD569-0004Gy-Rx for pgsql-performance@postgresql.org (return-path ); Sun, 29 Jun 2008 22:10:18 +0000 Message-ID: <48680860.2000300@wizmail.org> Date: Sun, 29 Jun 2008 23:10:40 +0100 From: Jeremy Harris User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.14) Gecko/20080501 Fedora/2.0.0.14-1.fc7 Thunderbird/2.0.0.14 Mnenhy/0.7.5.0 MIME-Version: 1.0 To: Pgsql-Performance Subject: Re: sequence scan problem References: <48680418.7030708@gmail.com> In-Reply-To: <48680418.7030708@gmail.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: 200806/214 X-Sequence-Number: 30564 John Beaver wrote: > I'm having a strange problem with a query. The query is fairly simple, > with a few constants and two joins. All relevant columns should be > indexed, and I'm pretty sure there aren't any type conversion issues. > But the query plan includes a fairly heavy seq scan. The only possible > complication is that the tables involved are fairly large - hundreds of > millions of rows each. > > Can anyone explain this? There should only ever be a maximum of about 50 > rows returned when the query is executed. You didn't say when you last vacuumed? If there should only be 50 rows returned then the estimates from the planner are way out. If that doesn't help, we'll need version info, and (if you can afford the time) an "explain analyze" Cheers, Jeremy