Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 55119650EBD for ; Mon, 30 Jun 2008 00:33:18 -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 80294-06 for ; Mon, 30 Jun 2008 00:32:54 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 1E6D0650E8B for ; Mon, 30 Jun 2008 00:31:38 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m5U3VZwq010567; Sun, 29 Jun 2008 23:31:36 -0400 (EDT) To: John Beaver cc: Pgsql-Performance Subject: Re: sequence scan problem In-reply-to: <48680418.7030708@gmail.com> References: <48680418.7030708@gmail.com> Comments: In-reply-to John Beaver message dated "Sun, 29 Jun 2008 17:52:24 -0400" Date: Sun, 29 Jun 2008 23:31:35 -0400 Message-ID: <10566.1214796695@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200806/217 X-Sequence-Number: 30567 John Beaver writes: > Can anyone explain this? There should only ever be a maximum of about 50 > rows returned when the query is executed. Is the estimate that 197899 rows of gene_prediction_view have go_term_ref = 2 about right? If not, then we need to talk about fixing your statistics. If it is in the right ballpark then I do not see *any* plan for this query that runs in small time. The only way to avoid a seqscan on functional_linkage_scores would be to do 198K^2 index probes into it, one for each combination of matching fs1 and fs2 rows; I can guarantee you that that's not a win. The fact that the planner is estimating 352770803726 result rows compared to your estimate of 50 offers some hope that it's a stats problem, but ... regards, tom lane