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

Tom Lane wrote:

>
>There is probably some minuscule cost difference involved --- you save
>parsing and parse analysis of a long query string.  On the other hand,
>you pay to pull the view definition from the catalogs and merge it into
>the given query.  I'd not care to hazard a guess on whether the actual
>net cost is more or less; but in any case these costs will be swamped
>by query planning and execution, if the query is complex.
>
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.




view thread (5+ messages)  latest in thread

Message-ID: <3E9C63A8.4040801@web.de>
Permalink:  ../3E9C63A8.4040801@web.de/
Also on:    postgresql.org/message-id/3E9C63A8.4040801@web.de

 · 

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: Andreas.Pflug@web.de
  Subject: Re: Do Views offer any performance advantage?
  In-Reply-To: <3E9C63A8.4040801@web.de>
  References: <001f01c30366$93427720$f3b0313e@LAIKA> <8832.1050427583@sss.pgh.pa.us> <3E9C63A8.4040801@web.de>

* 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