Re: UNION ALL has higher cost than inheritance
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Greg Stark <gsstark@mit.edu>
Cc: Itagaki Takahiro <itagaki.takahiro@gmail.com>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2010-11-08T04:00:08Z
Lists: pgsql-hackers
Attachments
- top-level-union-all.patch (text/x-patch) patch
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