Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id C63DD9FB3B6 for ; Wed, 18 Oct 2006 20:05:35 -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 34679-06 for ; Wed, 18 Oct 2006 23:05:28 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id E448B9FB2E6 for ; Wed, 18 Oct 2006 20:05:27 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k9IN5HXa002695; Wed, 18 Oct 2006 19:05:17 -0400 (EDT) To: Jeff Davis cc: "Jim C. Nasby" , Dimitri Fontaine , pgsql-performance@postgresql.org, Ioana Danes Subject: Re: Postgresql 8.1.4 - performance issues for select on In-reply-to: <1161210735.31645.277.camel@dogma.v10.wvs> 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> <1161210735.31645.277.camel@dogma.v10.wvs> Comments: In-reply-to Jeff Davis message dated "Wed, 18 Oct 2006 15:32:15 -0700" Date: Wed, 18 Oct 2006 19:05:17 -0400 Message-ID: <2694.1161212717@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200610/389 X-Sequence-Number: 21518 Jeff Davis writes: > 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? It's something on the wish-list. Personally I'd be inclined to try to rewrite the query as a plain MAX() across rewritten per-table indexed queries, rather than worry about mergesort or anything like that. There wasn't any very good way to incorporate that idea when planagg.c was first written, but now that the planner has an explicit notion of "append relations" it might be relatively straightforward. regards, tom lane