Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl> writes:
> Say I have:
> select foo (
> select foo from bar1
> union all
> select foo from bar2
> union all
> select foo from bar3
> ) a order by foo desc limit X;
> (and I can give you few other examples around the same 'note', say with when
> foo=N in outer subselect)
> Would anyone consider such optimization, when postgres will apply the same
> condition to inner queries, providing that their size is substantial?
Well you haven't said what optimization you're looking for here.
I posted a patch to look for an ordered path for members of a union a while
back but it still needed a fair amount of work before it was usable.
The LIMIT can't be pushed into the union unless we do have ordered paths so
that's further down the line. (And even then it would only work if there are
no conditions on there append path.)
And I believe we already do push down where clauses like foo=N.
> Same would actually apply for different subqueries, without union/
> select foo( select foo from bar1 ) a where foo in (x,y,z) order by foo desc
> limit N
Ask me about EnterpriseDB's RemoteDBA services!
In response to
pgsql-hackers by date
|Next:||From: Grzegorz Jaskiewicz||Date: 2009-02-28 11:49:07|
|Subject: Re: would it be a lot of work, to add optimizations accross unions ?|
|Previous:||From: James Pye||Date: 2009-02-28 10:51:27|
|Subject: Re: xpath processing brain dead|