Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 55CDB650EEA for ; Sun, 29 Jun 2008 19:20:27 -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 88471-02 for ; Sun, 29 Jun 2008 19:20:20 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from yw-out-2324.google.com (yw-out-2324.google.com [74.125.46.30]) by postgresql.org (Postfix) with ESMTP id 4F8A9650EF7 for ; Sun, 29 Jun 2008 19:20:24 -0300 (ADT) Received: by yw-out-2324.google.com with SMTP id 3so596870ywj.73 for ; Sun, 29 Jun 2008 15:20:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=T0Hrf+uellJtD3XCzvtsQUE2dhPXBw1TVWkEQWMdrH4=; b=j6NexVDAfl48NnOdV9A8Ak51+mw3H+/UAEMl/cRK+lURRR7DoWQvyKI9syTvD2OaKh D4RfTOTPLtxS+CihRoCJf9Ba2mLhpqulnqTp3urqwDfRuNKb61DVBlXeJfqCTXAxrO1A N3mQ2nDLDBZvFOPwKHaTC2rRlBZpXzA1HHr1Y= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=HUROwb3K/ofBJBgWFzeUwNfp8krLqmQBwtRueQbpZGX2XLxTA7xlHFdJPzoZNVQoYf ZEuZ1PJ+wy2PgsJbscUppA3G+3XNfIidy9T/4BBSKL3KBBY4aCLqxgzxx3COQRMCOTWJ IhtiovYTP3RvBm1Sm0puiCvgqSnm3NMuSAS14= Received: by 10.150.154.6 with SMTP id b6mr7139619ybe.28.1214778021730; Sun, 29 Jun 2008 15:20:21 -0700 (PDT) Received: from john-beavers-macbook-pro-2.local ( [24.218.26.7]) by mx.google.com with ESMTPS id 5sm497969yxt.1.2008.06.29.15.20.20 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 29 Jun 2008 15:20:21 -0700 (PDT) Message-ID: <48680AA4.2070800@gmail.com> Date: Sun, 29 Jun 2008 18:20:20 -0400 From: John Beaver User-Agent: Thunderbird 2.0.0.14 (Macintosh/20080421) MIME-Version: 1.0 To: Jeremy Harris CC: Pgsql-Performance Subject: Re: sequence scan problem References: <48680418.7030708@gmail.com> <48680860.2000300@wizmail.org> In-Reply-To: <48680860.2000300@wizmail.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.315 tagged_above=0 required=5 tests=SARE_MILLIONSOF=0.315 X-Spam-Level: X-Archive-Number: 200806/215 X-Sequence-Number: 30565 Jeremy Harris wrote: > 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? I ran 'vacuum analyze' on both tables directly after I finished building them, and I haven't updated their contents since. > 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" Sure, I'm running it now. I'll send the results when it's done, but yes, it could take a while. > > Cheers, > Jeremy >