Re: Functions or Rules and Views?

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Rory Campbell-Lange <rory(at)campbell-lange(dot)net>, pgsql-novice(at)postgresql(dot)org
Subject: Re: Functions or Rules and Views?
Date: 2003-05-26 23:40:57
Message-ID: 200305261640.57729.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Rory,

> I'm embarking on a new project and have been reading up on the new v7.3
> functions. I have a few general questions about how to use these and
> whether or not I should use functions exclusively, or also use rules and
> views.

I generally use a mix of views, triggers, and data-push functions.

> Are there any penalties in terms of the speed of execution of a function
> over a view?

A SELECT view will generally be much faster than a rowset-returning function,
and is usually more easily adapted for partial selects, re-ordering, etc.

I have not compared the execution speed of updatable views + rules vs.
data-push functions, as I use the latter almost exclusively since they allow
me to bundle security and rights checking, and custom error messages, into
the same function, something which is more cumbersome with updatable views.

However, it depends on your users and your application. If you have an app
where some of the users will utilize direct SQL access, then rules may be a
better choice.

--
Josh Berkus
Aglio Database Solutions
San Francisco

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Israel Calderon 2003-05-27 01:32:08 Creation of Redundant Tables.
Previous Message Nabil Sayegh 2003-05-26 19:46:00 Re: add foreign key constraint after table creation?