Re: Performance of views

From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Simon Windsor <simon(dot)windsor(at)cornfield(dot)me(dot)uk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Performance of views
Date: 2008-11-03 01:39:14
Message-ID: 20081103013914.GV4452@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Simon,

* Simon Windsor (simon(dot)windsor(at)cornfield(dot)me(dot)uk) wrote:
> Generally, I have avoided using VIEWS within application code and only
> used them for client interfaces, the sole reason being the performance
> of views against tables.

Views really shouldn't have a large impact on overall performance. In
PostgreSQL, that's even more true. In general, I would strongly
recommend moving complex queries from your application into views in the
database. The performance difference really should be minimal, while
the maintainability is improved.

> * Data within a view is not necessary sequential, unlike a table

I've got no idea what you're talking about here, to be honest. Pulling
data out of a table has no guarenteed ordering to it unless you
explicitly ask for one, and you can do that in a view too.

> * Higher overhead mapping to original tables and indexes

This just plain isn't true in PG, at least, and I'd think most other
sensible databases..

> * Danger of linking views and tables and not utilising utilising
> underlying tables properly.

If you push your complicated queries into your views and keep the
application code simpler, identifying and fixing performance or other
issues often becomes easier, and easier to fix..

> Am I right to avoid to VIEWS within application code?

No.

Thanks,

Stephen

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Craig Ringer 2008-11-03 01:54:18 Re: Are there plans to add data compression feature to postgresql?
Previous Message Tom Lane 2008-11-03 01:34:09 Re: Are there plans to add data compression feature to postgresql?