On Fri, Feb 28, 2014 at 02:35:50PM +0900, Kyotaro HORIGUCHI wrote: > At Thu, 27 Feb 2014 21:53:52 -0500, Noah Misch wrote > > On Thu, Feb 27, 2014 at 05:33:47PM -0500, Tom Lane wrote: > > > I wonder whether we should consider adding a pass to flatten any nested > > > appendrels after we're done creating them all. > > > > We did consider that upthread. It's a valid option, but I remain more > > inclined to teach pull_up_subqueries() to preserve flatness just like > > expand_inherited_tables() will. > > Yes, the old dumped version of typ2 patch did so. It flattened > appendrel tree for the query prpoerly. Let me hear the reson you > prefer to do so.
Having reviewed my upthread reasoning for preferring one of those two approaches over the other, it's a weak preference. They have similar runtime costs. Putting the logic with the code that creates appendrels reduces the number of code sites one must examine to reason about possible plan structures. We might not flatten RTE_RELATION appendrel parents exactly the same way we flatten RTE_SUBQUERY appendrel parents. I would tend to leave inh=true for the former, for reasons explained in my notes on v7, but set inh=false for the latter to save needless work. On the other hand, a flattening pass is less code overall and brings an attractive uniformity-by-default to the area. -- Noah Misch EnterpriseDB http://www.enterprisedb.com -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers