Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 73332650E80 for ; Mon, 30 Jun 2008 12:26:06 -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 85242-02 for ; Mon, 30 Jun 2008 12:25:59 -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 85045650DBC for ; Mon, 30 Jun 2008 12:25:58 -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 m5UFPtbD029000; Mon, 30 Jun 2008 11:25:55 -0400 (EDT) To: John Beaver cc: Jeremy Harris , Pgsql-Performance Subject: Re: sequence scan problem In-reply-to: <4868BC74.6020006@gmail.com> References: <48680418.7030708@gmail.com> <48680860.2000300@wizmail.org> <4868BC74.6020006@gmail.com> Comments: In-reply-to John Beaver message dated "Mon, 30 Jun 2008 06:59:00 -0400" Date: Mon, 30 Jun 2008 11:25:55 -0400 Message-ID: <28999.1214839555@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200806/237 X-Sequence-Number: 30587 John Beaver writes: > Ok, here's the explain analyze result. Again, this is Postgres 8.3.3 and > I vacuumed-analyzed both tables directly after they were created. > Merge Join (cost=1399203593.41..6702491234.74 rows=352770803726 > width=22) (actual time=6370194.467..22991303.434 rows=15610535128 loops=1) ^^^^^^^^^^^ Weren't you saying that only 50 rows should be returned? I'm thinking the real problem here is pilot error: you missed out a needed join condition or something. SQL will happily execute underconstrained queries ... regards, tom lane