Received: from candle.pha.pa.us (pgman@s5-03.ppp.op.net [209.152.195.67]) by hub.org (8.9.3/8.9.3) with ESMTP id TAA85913 for ; Fri, 17 Dec 1999 19:34:54 -0500 (EST) (envelope-from pgman@candle.pha.pa.us) Received: (from pgman@localhost) by candle.pha.pa.us (8.9.0/8.9.0) id TAA19361; Fri, 17 Dec 1999 19:32:05 -0500 (EST) From: Bruce Momjian Message-Id: <199912180032.TAA19361@candle.pha.pa.us> Subject: Re: [SQL] Sub-select speed. In-Reply-To: <11757.945473101@sss.pgh.pa.us> from Tom Lane at "Dec 17, 1999 06:25:01 pm" To: Tom Lane Date: Fri, 17 Dec 1999 19:32:05 -0500 (EST) CC: Mitch Vincent , pgsql-sql@postgreSQL.org X-Mailer: ELM [version 2.4ME+ PL65 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit > Bruce Momjian writes: > >> There has been some talk of automatically rewriting queries to eliminate > >> unnecessary sub-selects, but I don't foresee it getting done for a > >> while yet. > > > Tom, you mentioned that subselects use nested join, but they could be > > hardcoded to use hash join. My opinion is that this should be done if > > it is easy. > > That would probably help for uncorrelated subselects (where no variable > from the outer query is referenced in the inner one). For correlated > subselects, such as this one is, hashing the subselect result isn't > going to help much --- the real problem is that the subselect is > repeated afresh for each outer tuple. Oh, I was thinking in general of our EXISTS() workaround and if we could help that by forcing hash joins. -- Bruce Momjian | http://www.op.net/~candle maillist@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026