X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 6A39FD1BCC2 for ; Mon, 22 Mar 2004 19:32:21 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 49019-07 for ; Mon, 22 Mar 2004 15:32:30 -0400 (AST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id 11E84D1B97B for ; Mon, 22 Mar 2004 15:32:19 -0400 (AST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 66AAE3596E; Mon, 22 Mar 2004 11:32:30 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 652E135969; Mon, 22 Mar 2004 11:32:30 -0800 (PST) Date: Mon, 22 Mar 2004 11:32:30 -0800 (PST) From: Stephan Szabo To: Joseph Shraibman Cc: Tom Lane , pgsql-performance@postgresql.org Subject: Re: two seperate queries run faster than queries ORed In-Reply-To: <405F37CE.9070302@selectacast.net> Message-ID: <20040322113002.D62908@megazone.bigpanda.com> References: <200403221655.28667.dev@archonet.com> <405F2893.5090805@selectacast.net> <6875.1079979859@sss.pgh.pa.us> <405F37CE.9070302@selectacast.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200403/295 X-Sequence-Number: 6151 On Mon, 22 Mar 2004, Joseph Shraibman wrote: > Tom Lane wrote: > > Joseph Shraibman writes: > > > >>No, pkey is not the primary key in this case. The number of entries in u > >>that have pkey 260 and not boolfield is 344706. > > > > > > ... and every one of those rows *must* be included in the join input, > > *If* you use one big join in the first place. If postgres ran the query > to first get the values with status == 3 from u, then ran the query to > get the entries from d, then combined them, the result would be the same > but the output faster. Instead it is doing seq scans on both tables and Well, you have to be careful on the combination to not give the wrong answers if there's a row with u.status=3 that matches a row d.status=3.