Re: When to choose putting logic into PL/pgSQL and when to use an app server

From: Rory Campbell-Lange <rory(at)campbell-lange(dot)net>
To: Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: When to choose putting logic into PL/pgSQL and when to use an app server
Date: 2012-03-10 16:45:01
Message-ID: 20120310164501.GC17838@campbell-lange.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On 10/03/12, Frank Lanitz (frank(at)frank(dot)uvena(dot)de) wrote:
> I started to get into PL/pgSQL a bit as I'm started to work at an
> application where I might can make usage of it. But I'm not sure even
> those I read a bunch of documentation where is it useful to put logic
> into database server and when I shall do the computing inside an
> application layer... Does anyone of you have some kind of rule of a
> thumb about that?

It might depend on what sort of logic you are referring to. Some web
frameworks provide very simple ways of persisting objects to the
database and then querying these which are fine for many applications.

If your data model requires good quality data and you are making heavy
use of the relational aspects of the database, plpgsql can be an
excellent choice.

Wherever you do the bulk of the data "logic" you will no doubt be doing
some work in SQL even if you are using an Object-Relational Mapper
(ORM), or in the middleware language even if you are using plpgsql.
Things like web forms are best validated in the middleware.

From our experience we have altered our web frontend and middleware
several times over the last 7 years while running much the same plpgsql
functions. We are very happy with this arrangement.

Rory

--
Rory Campbell-Lange
rory(at)campbell-lange(dot)net

Campbell-Lange Workshop
www.campbell-lange.net
0207 6311 555
3 Tottenham Street London W1T 2AF
Registered in England No. 04551928

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Gavin Flower 2012-03-10 19:38:24 Re: When to choose putting logic into PL/pgSQL and when to use an app server
Previous Message Tom Lane 2012-03-10 16:14:53 Re: float to numeric(7,3)