Re: Performance of views - Mailing list pgsql-general

From Stephen Frost
Subject Re: Performance of views
Date
Msg-id 20081103013914.GV4452@tamriel.snowman.net
Whole thread Raw
In response to Performance of views  (Simon Windsor <simon.windsor@cornfield.me.uk>)
Responses Re: Performance of views
List pgsql-general
Simon,

* Simon Windsor (simon.windsor@cornfield.me.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

Attachment

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Are there plans to add data compression feature to postgresql?
Next
From: Craig Ringer
Date:
Subject: Re: Are there plans to add data compression feature to postgresql?