pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Antoine Reid <antoiner@hansonpublications.com>
To: Madel, Kurt <KMadel@USInspect.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Use a rule or a transaction
Date: Tue, 15 Aug 2000 14:43:14 -0400
Message-ID: <20000815144314.A21306@wumpus.lan.edmarketing.com> (raw)
In-Reply-To: <C6F9B91B745CD4119F1500A0C9DD60C02E348E@exchhq01.usinspect.com>
References: <C6F9B91B745CD4119F1500A0C9DD60C02E348E@exchhq01.usinspect.com>

On Tue, Aug 15, 2000 at 01:57:17PM -0400, Madel, Kurt wrote:
> Hello,
> 
> I am creating a web based (using php) class registration database with three
> tables directly effected by the registration process:

[snip]

> My question is, would it be better (faster) to use rules or to use a
> transaction.

How about using triggers?  I have used pl/pgsql triggers in the past to do
similar things.  I was not checking a maximum but definitely was keeping a
reference count.  What you want is a trigger that increments on insert,
decrement on delete, and on update, IF the id changed, decrement the old
one, increment the new one..  I suspect you could also have another trigger,
on update on class, that would abort the transaction if class.size ever
becomes bigger than maxsize..

I can't really comment on performance though.....

> Is there a faster way to do this with rules or a better way to do it
> otherwise.
> 
> TIF,
> Kurt

Hope it helps
Antoine

-- 
 o          Antoine Reid             o>    Alcohol and calculus   <o>
<|> antoiner@hansonpublications.com <|    don't mix. Never drink   |
 >\    antoiner@edmarketing.com      >\         and derive.       /<



view thread (8+ messages)  latest in thread

Message-ID: <20000815144314.A21306@wumpus.lan.edmarketing.com>
Permalink:  ../20000815144314.A21306@wumpus.lan.edmarketing.com/
Also on:    postgresql.org/message-id/20000815144314.A21306@wumpus.lan.edmarketing.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: antoiner@hansonpublications.com, KMadel@USInspect.com
  Subject: Re: Use a rule or a transaction
  In-Reply-To: <20000815144314.A21306@wumpus.lan.edmarketing.com>
  References: <C6F9B91B745CD4119F1500A0C9DD60C02E348E@exchhq01.usinspect.com> <20000815144314.A21306@wumpus.lan.edmarketing.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox