Re: Views- Advantages and Disadvantages

From: "Merlin Moncure" <mmoncure(at)gmail(dot)com>
To: "Ashish Karalkar" <ashish(dot)karalkar(at)info-spectrum(dot)com>
Cc: woodb(at)niwa(dot)co(dot)nz, "Postgres General" <pgsql-general(at)postgresql(dot)org>, "Andrej Ricnik-Bay" <andrej(dot)groups(at)gmail(dot)com>
Subject: Re: Views- Advantages and Disadvantages
Date: 2007-05-09 14:16:40
Message-ID: b42b73150705090716p1005c429ud566aa26cdc429a0@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 5/9/07, Ashish Karalkar <ashish(dot)karalkar(at)info-spectrum(dot)com> wrote:
> Thanks Brent for your replay,
>
>
> What about the Disadvantages, Performance issues [of views]

Views are pretty much neutral from a performance perspective. There
are certain small considerations here and there to think about but you
should really be focusing on how they impact your development and
design strategies.

Probably there are two disadvantages of using views. The first is
that the introduce dependencies on your tables so that whenever you
need to certain things to your table you have to drop the view, do the
thing (like drop a column) and re-create the view. Second issue is
that views are not updatable without the introduction of rules which
are extra dependencies and can be tricky to write.

Now the first problem is not really a problem...in fact, views are a
great way to tell the dba what applications are doing and gives him a
chance to introduce application compatibility if the table structures
change. So I count this as a feature of using views although it will
feel like extra work to do, especially in the beginning. At some
point, views (especially trivial ones) in PostgreSQL will become
automatically updatable which will mitigate the impact of the second
disadvantage. If and when that happens,

IMNSHO, Views are a critical foundation to good development. Complex
queries drifting around in various applications is A Bad Thing, and
views allow you to control this and provide much better encapsulation
of the database and exercise control over what's going on. Many
application developers are uncomfortable with the idea of views (and
other high level database features like functions) but when used
properly, the benefits they can bring to your development and
maintenance can be really dramatic. Use them.

merlin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Scott Ribe 2007-05-09 14:26:52 Re: Dangers of fsync = off
Previous Message Alvaro Herrera 2007-05-09 14:13:52 Re: PG on Debian 4.0.x ?