pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andreas Pflug <Andreas.Pflug@web.de>
Cc: pgsql-performance@postgresql.org
Subject: Re: Do Views offer any performance advantage?
Date: Tue, 15 Apr 2003 19:37:06 -0400
Message-ID: <11035.1050449826@sss.pgh.pa.us> (raw)
In-Reply-To: <3E9C63A8.4040801@web.de>
References: <001f01c30366$93427720$f3b0313e@LAIKA>
	<8832.1050427583@sss.pgh.pa.us>
	<3E9C63A8.4040801@web.de>

Andreas Pflug <Andreas.Pflug@web.de> writes:
> Actually, there are cases when a view can impact performance.
> If you are joining a view, it seems to be treated as a subquery, that 
> might have a much larger result than you would like.

> Imagine
> SELECT something
>   FROM A JOIN B JOIN C ...
>  WHERE A.primaryKeyFoo=1234 ...

>  where C is a view, containing JOINs itself, I observed a query plan 
> (7.3.2) like
> A JOIN B JOIN (D JOIN E)
> instead of
> A JOIN B JOIN D JOIN E which would be much more efficient for the 
> A.primaryKeyFoo restriction.

This is not the view's fault though --- the same would have happened
if you'd written explicitly

	FROM A JOIN B JOIN (D JOIN E)

7.4 will be less rigid about this (with or without a view ...)

			regards, tom lane




view thread (5+ messages)  latest in thread

Message-ID: <11035.1050449826@sss.pgh.pa.us>
Permalink:  ../11035.1050449826@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/11035.1050449826@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-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, Andreas.Pflug@web.de
  Subject: Re: Do Views offer any performance advantage?
  In-Reply-To: <11035.1050449826@sss.pgh.pa.us>
  References: <001f01c30366$93427720$f3b0313e@LAIKA> <8832.1050427583@sss.pgh.pa.us> <3E9C63A8.4040801@web.de> <11035.1050449826@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