pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gordon A. Runkle <gar@integrated-dynamics.com>
To: pgsql-sql@postgresql.org
Subject: Re: UNION in a VIEW?
Date: Thu, 05 Apr 2001 09:30:18 -0400
Message-ID: <9ahrl7$1aih$1@news.tht.net> (raw)
References: <web-34027@davinci.ethosmedia.com>

In article <web-34027@davinci.ethosmedia.com>, "Josh Berkus"
<josh@agliodbs.com> wrote:

> Tom, Gordon,
> Hmmm ... I'm pretty used an external WHERE clause being applied to the
> output of the view, rather than pushed down into the member selects of
> the UNION, in the same way as if the UNION query were a subselect.
> Coming from a SQL Server background, I'd actually find the suggested
> behavior rather confusing (as well as tough for you guys to implement).

Like I said, I'm not a backend guru.  However, SQL Server and DB2
both *appear* to be pushing down the WHERE clause.  They may not be,
but they both process the query nearly instantaneously on large
tables, which leads me to speculate that they do.  PostgreSQL goes
off and munches for a *long* time on the same view/query, whereas if
I write a query which explicitly distributes the WHERE then PostgreSQL
processes the query very fast (faster than DB2 or SQL Server).

So, I can only guess what's happening "behind the curtain", but this
is what I'm observing.

Plus, I think that if the WHERE clause were applied to the results
of the VIEW, that would require storing those results in temp space,
and for large tables would be very slow.  I believe that's the whole
reason that VIEWs' underlying queries can be merged/rewritten with
the "calling" query?

Thanks,

Gordon.
-- 
It doesn't get any easier, you just go faster.
   -- Greg LeMond



view thread (8+ messages)  latest in thread

Message-ID: <9ahrl7$1aih$1@news.tht.net>
Permalink:  ../9ahrl7$1aih$1@news.tht.net/
Also on:    postgresql.org/message-id/9ahrl7$1aih$1@news.tht.net

 · 

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-sql@postgresql.org
  Cc: gar@integrated-dynamics.com
  Subject: Re: UNION in a VIEW?
  In-Reply-To: <9ahrl7$1aih$1@news.tht.net>
  References: <web-34027@davinci.ethosmedia.com> <9ahrl7$1aih$1@news.tht.net>

* 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