Re: Do Views offer any performance advantage? - Mailing list pgsql-performance

From Tom Lane
Subject Re: Do Views offer any performance advantage?
Date
Msg-id 11035.1050449826@sss.pgh.pa.us
Whole thread Raw
In response to Re: Do Views offer any performance advantage?  (Andreas Pflug <Andreas.Pflug@web.de>)
Responses Re: Do Views offer any performance advantage?  (Andreas Pflug <Andreas.Pflug@web.de>)
List pgsql-performance
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


pgsql-performance by date:

Previous
From: Andreas Pflug
Date:
Subject: Re: Do Views offer any performance advantage?
Next
From: "dex"
Date:
Subject: Is there a performance between Inherits and Views?