Re: Do Views offer any performance advantage?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andreas Pflug <Andreas(dot)Pflug(at)web(dot)de>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Do Views offer any performance advantage?
Date: 2003-04-15 23:37:06
Message-ID: 11035.1050449826@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Andreas Pflug <Andreas(dot)Pflug(at)web(dot)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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message dex 2003-04-16 06:10:44 Is there a performance between Inherits and Views?
Previous Message Andreas Pflug 2003-04-15 19:55:20 Re: Do Views offer any performance advantage?