Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 997509FA1DA for ; Wed, 18 Oct 2006 19:32:54 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 16952-07 for ; Wed, 18 Oct 2006 22:32:50 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from servata.com (ip-216-152-249-241.servata.com [216.152.249.241]) by postgresql.org (Postfix) with ESMTP id F3D289F9425 for ; Wed, 18 Oct 2006 19:32:49 -0300 (ADT) Received: from [209.162.219.253] (helo=dogma.v10.wvs) by servata.com with esmtpa (Exim 4.50) id 1GaJxS-0008OF-G6; Wed, 18 Oct 2006 15:32:18 -0700 Subject: Re: Postgresql 8.1.4 - performance issues for select on From: Jeff Davis To: "Jim C. Nasby" Cc: Dimitri Fontaine , pgsql-performance@postgresql.org, Ioana Danes In-Reply-To: <20061018221046.GG85041@nasby.net> References: <20061018210201.56435.qmail@web55907.mail.re3.yahoo.com> <200610182319.41920.dim@dalibo.com> <1161207230.31645.266.camel@dogma.v10.wvs> <20061018221046.GG85041@nasby.net> Content-Type: text/plain Date: Wed, 18 Oct 2006 15:32:15 -0700 Message-Id: <1161210735.31645.277.camel@dogma.v10.wvs> Mime-Version: 1.0 X-Mailer: Evolution 2.0.4 (2.0.4-7) Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.134 tagged_above=0 required=5 tests=FORGED_RCVD_HELO, SPF_HELO_PASS X-Spam-Level: X-Archive-Number: 200610/383 X-Sequence-Number: 21512 On Wed, 2006-10-18 at 17:10 -0500, Jim C. Nasby wrote: > Sorry, don't have the earlier part of this thread, but what about... > > SELECT greatest(max(a), max(b)) ... > > ? To fill you in, we're trying to get the max of a union (a view across two physical tables). It can be done if you're creative with the query; I suggested a query that selected the max of the max()es of the individual tables. Your query could work too. However, the trick would be getting postgresql to recognize that it can transform "SELECT max(x) FROM foo" into that, where foo is a view of a union. If PostgreSQL could sort the result of a union by merging the results of two index scans, I think the problem would be solved. Is there something preventing this, or is it just something that needs to be added to the planner? Regards, Jeff Davis