pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Stephan Szabo <sszabo@megazone23.bigpanda.com>
Cc: Gaetano Mendola <mendola@bigfoot.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: Union strange explain
Date: Thu, 04 Jul 2002 20:27:57 -0400
Message-ID: <6645.1025828877@sss.pgh.pa.us> (raw)
In-Reply-To: <20020704115011.T19207-100000@megazone23.bigpanda.com>
References: <20020704115011.T19207-100000@megazone23.bigpanda.com>

Stephan Szabo <sszabo@megazone23.bigpanda.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





view thread (5+ messages)  latest in thread

Message-ID: <6645.1025828877@sss.pgh.pa.us>
Permalink:  ../6645.1025828877@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/6645.1025828877@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: tgl@sss.pgh.pa.us, sszabo@megazone23.bigpanda.com, mendola@bigfoot.com
  Subject: Re: Union strange explain
  In-Reply-To: <6645.1025828877@sss.pgh.pa.us>
  References: <20020704115011.T19207-100000@megazone23.bigpanda.com> <6645.1025828877@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox