Re: Union strange explain

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
Cc: Gaetano Mendola <mendola(at)bigfoot(dot)com>, pgsql-admin(at)postgresql(dot)org
Subject: Re: Union strange explain
Date: 2002-07-05 00:27:57
Message-ID: 6645.1025828877@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> writes:
> I think there was some question about
> whether it was safe to do that optimization (ie,
> is select * from (a union [all] b) where condition
> always the same as
> select * from a where condition union [all]
> select * from b where condition
> )
> This was discussed recently, but I forget what the final determination
> was.

There wasn't any final determination --- it's still an open issue
whether there are any limitations the planner would have to consider
when trying to push down conditions into UNIONs. Offhand it seems
to me that the change is always safe when dealing with UNION ALL,
but I'm not quite convinced about UNION. And what of INTERSECT
and EXCEPT?

Another interesting question is whether there are cases where the
planner could legally push down the condition, but should not because
it would end up with a slower plan. I can't think of any examples
offhand, but that doesn't mean there aren't any.

regards, tom lane

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Gregor Mosheh 2002-07-05 01:11:52 memory strangeness (fwd)
Previous Message Bruce Momjian 2002-07-05 00:10:34 Re: Performance impact of record sizes