Re: Views

From: Joshua Tolley <eggyknap(at)gmail(dot)com>
To: David Saracini <dsaracini(at)yahoo(dot)com>
Cc: pgsql novice forum <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Views
Date: 2009-06-13 20:37:33
Message-ID: 20090613203733.GN12253@eddie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Sat, Jun 13, 2009 at 08:45:22AM -0700, David Saracini wrote:
> Hello All,
> With Postgres, is there anything to be aware of when using/creating views.
> Any performance considerations? In my experience, this is an areas where
> performance can vary greatly across DBMSs.
> Many thanks (in advance)!

Using a view in a query is effectively the same thing as using the view's query
as a subquery. In other words, if view foo is built on query bar, as in CREATE
VIEW foo AS bar, when you say "SELECT * FROM foo", the backend rewrites your
query as "SELECT * FROM (bar) foo". So the mechanics of using a view don't
make any noticeable difference in query parsing. There are sometimes cases
where queries involving several views that reference the same set of tables
can be rewritten more efficiently without views, because the optimizer isn't
clever enough do some of the collapsing that could be done, but that's no
differnet than if you composed a query from a bunch of subqueries.

- Josh / eggyknap

In response to

  • Views at 2009-06-13 15:45:22 from David Saracini

Browse pgsql-novice by date

  From Date Subject
Next Message Jana 2009-06-14 13:36:34 Delete performance
Previous Message Bruce Hyatt 2009-06-13 18:21:07 Re: Yum Update Errors