X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 433DB52844 for ; Thu, 26 May 2005 15:02:46 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 95723-03 for ; Thu, 26 May 2005 18:02:36 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id CB69452824 for ; Thu, 26 May 2005 15:02:35 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4QI2aWG003884; Thu, 26 May 2005 14:02:36 -0400 (EDT) To: Sam Mason Cc: pgsql-performance@postgresql.org Subject: Re: Optimising queries involving unions In-reply-to: <20050526174203.GK15205@colo.samason.me.uk> References: <20050526152203.GI15205@colo.samason.me.uk> <3339.1117126434@sss.pgh.pa.us> <20050526174203.GK15205@colo.samason.me.uk> Comments: In-reply-to Sam Mason message dated "Thu, 26 May 2005 18:42:03 +0100" Date: Thu, 26 May 2005 14:02:36 -0400 Message-ID: <3883.1117130556@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/399 X-Sequence-Number: 12563 Sam Mason writes: > Tom Lane wrote: >> It'd be nice to fix this someday, but don't hold your breath ... > Is it even worth me thinking about trying to figure out how to make > the current code do this sort of thing? Probably not :-(. What we need is to integrate UNION (and the other set-ops) into the normal querytree structure so that the planner can consider alternative plans within its existing framework. That requires some fundamental changes in the Query structure --- in particular, we have to get rid of the current situation that there is exactly one targetlist per rangetable. Decoupling targetlists and rangetables would have some other benefits too (INSERT ... SELECT would get a lot cleaner) but it's a wide-ranging change, and I think could only usefully be tackled by someone who is already pretty familiar with the code. regards, tom lane