Re: [HACKERS] EquivalenceClasses and subqueries and PlaceHolderVars, oh my

2012-03-17 Thread Tom Lane
Greg Stark writes: > On Fri, Mar 16, 2012 at 3:16 PM, Tom Lane wrote: > So I now propose reverting the earlier two patches (but not their > regression test cases of course) and instead hacking MergeAppend plan > building as per (2). > As a wise man once said, "This is tricky stuff". I feel a bet

Re: [HACKERS] EquivalenceClasses and subqueries and PlaceHolderVars, oh my

2012-03-16 Thread Greg Stark
On Fri, Mar 16, 2012 at 3:16 PM, Tom Lane wrote: >> So I now propose reverting the earlier two patches (but not their >> regression test cases of course) and instead hacking MergeAppend plan >> building as per (2). As a wise man once said, "This is tricky stuff". I feel a better that I got stuck

Re: [HACKERS] EquivalenceClasses and subqueries and PlaceHolderVars, oh my

2012-03-16 Thread Tom Lane
I wrote: > So I now propose reverting the earlier two patches (but not their > regression test cases of course) and instead hacking MergeAppend plan > building as per (2). Attached is a draft patch for that. There are several things going on here: * Revert the preceding two patches (except for t

Re: [HACKERS] EquivalenceClasses and subqueries and PlaceHolderVars, oh my

2012-03-15 Thread Tom Lane
I wrote: > Yeb Havinga writes: >> I'm having a hard time imagining that add_child_rel_equivalences is not >> just plain wrong. Even though it will only add child equivalence members >> to a parent eq class when certain conditions are met, isn't it the case >> that since a union (all) is additio

Re: [HACKERS] EquivalenceClasses and subqueries and PlaceHolderVars, oh my

2012-03-15 Thread Tom Lane
Yeb Havinga writes: > On 2012-03-15 02:29, Tom Lane wrote: >>> There is an EquivalenceClass for each of "t1" and "t2", and if we don't >>> do something like wrapping the constants with distinct PHVs, then >>> add_child_rel_equivalences will end up pushing identical constants into >>> both ECs, thu

Re: [HACKERS] EquivalenceClasses and subqueries and PlaceHolderVars, oh my

2012-03-15 Thread Yeb Havinga
On 2012-03-15 02:29, Tom Lane wrote: > > explain select * from > (select thousand as t1, tenthous as t2 from tenk1 a > union all > select 42 as t1, 42 as t2 from tenk1 b) c > order by t1, t2; > > There is an EquivalenceClass for each of "t1" and "t2", and if we don't > do something like wrapp

[HACKERS] EquivalenceClasses and subqueries and PlaceHolderVars, oh my

2012-03-14 Thread Tom Lane
I looked into the problem complained of here: http://archives.postgresql.org/pgsql-bugs/2012-03/msg00016.php It's not at all specific to custom types; you can exhibit it with this query in the regression database: explain select * from (select 1 as t, unique1 from tenk1 a union all select 2 a