Re: UNION ALL has higher cost than inheritance

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: Itagaki Takahiro <itagaki(dot)takahiro(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: UNION ALL has higher cost than inheritance
Date: 2010-11-08 04:00:08
Message-ID: 8400.1289188808@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> The oversight here is that we don't use appendrel planning for
> a top-level UNION ALL construct. That didn't use to matter,
> because you always got the same stupid Append plan either way.
> Now it seems like we ought to have some more intelligence for the
> top-level SetOp case. I smell some code refactoring coming up.

I did some hacking on this and came up with the attached patch, which
could use a bit more work on the comments but passes regression tests.
However, this just solves the issue of being smart about top-level
UNION ALL cases. It might be worth looking into using MergeAppend
for the sorting required for other types of set operations. That would
involve quite a different patch, and I'm not sure if it'd remove the
need for this one or not.

regards, tom lane

Attachment Content-Type Size
top-level-union-all.patch text/x-patch 7.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Fetter 2010-11-08 04:09:08 Re: [Pgbuildfarm-members] Buildfarm client version 4.3 released
Previous Message Hitoshi Harada 2010-11-08 01:34:48 Re: SQL2011 and writeable CTE