Skip site navigation (1) Skip section navigation (2)

Re: would it be a lot of work, to add optimizations accross unions ?

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
Cc: PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: would it be a lot of work, to add optimizations accross unions ?
Date: 2009-02-28 11:37:55
Message-ID: 87fxhyssfg.fsf@oxford.xeocode.com (view raw or flat)
Thread:
Lists: pgsql-hackers
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/
> intersect/etc:
>
> select foo( select foo from bar1 ) a where foo in (x,y,z) order by foo  desc
> limit N

huh?

-- 
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com
  Ask me about EnterpriseDB's RemoteDBA services!

In response to

Responses

pgsql-hackers by date

Next:From: Grzegorz JaskiewiczDate: 2009-02-28 11:49:07
Subject: Re: would it be a lot of work, to add optimizations accross unions ?
Previous:From: James PyeDate: 2009-02-28 10:51:27
Subject: Re: xpath processing brain dead

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group