Re: Why are stored procedures looked on so negatively?

From: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "Some Developer *EXTERN*" <someukdeveloper(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Why are stored procedures looked on so negatively?
Date: 2013-07-24 05:04:08
Message-ID: A737B7A37273E048B164557ADEF4A58B17BF0B56@ntex2010a.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Some Developer wrote:
> On 24/07/13 01:55, John Meyer wrote:
> > Taking an absolutist position either way is pretty blind. What is the
> > purpose of the procedure? Is it enforcing business rules? Are these
> > rules that must be enforced against already existing data or are they
> > more akin to validation of a credit card. How many people are accessing
> > your database at one time? And most importantly, what are you best at?
>
> Basically what happens is an object is created in the application and
> saved to the database. When the insert has completed I need to start a
> process immediately based on the information in the object on another
> server (Amazon Simple Message Queue to be precise).
>
> So basically I'll have a trigger function that fires on INSERTs and does
> this work. That way the action will only be performed on INSERTs that
> have successfully completed and I can be sure that the trigger will
> always fire.

If you want to write a (trigger) function that starts a process on
a remote machine, there are a few points to think about:

- Should the INSERT fail if the remote process cannot be started?
If yes, then a trigger is a good idea.
- If you code it as a trigger, be aware that the transaction
is not complete until the remote process has been started.
That might be a noticable delay and might affect concurrency
negatively.

Yours,
Laurenz Albe

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Amit Langote 2013-07-24 05:56:31 Re: maintenance_work_mem and CREATE INDEX time
Previous Message Some Developer 2013-07-24 03:16:43 Re: Why are stored procedures looked on so negatively?