Re: Touch row ?

From: "Chris Travers" <chris(at)travelamericas(dot)com>
To: "Eric B(dot)Ridge" <ebr(at)tcdi(dot)com>, "Mike Mascari" <mascarm(at)mascari(dot)com>
Cc: "NTPT" <ntpt(at)centrum(dot)cz>, "PostgreSQL-general" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Touch row ?
Date: 2004-01-24 05:36:19
Message-ID: 016c01c3e23c$069f6390$97285e3d@winxp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-announce pgsql-general

I too have also noticed that the rule is a really cool way to write
lightweight triggers. They are also simpler to use, and often perform
better. You can also make them conditional which you cannot do with
triggers at the moment.

I think this timestamp concept is a perfect example of where a rule is
better. It doesn't have to be done on a view either.
For example:
CREATE TABLE mytable (
my_id SERIAL PRIMARY KEY,
last_updated TIMESTAMP);
CREATE RULE touch_row AS ON UPDATE TO mytable DO
(UPDATE mytable SET last_updated = NOW() WHERE my_id = NEW.my_id);

I assume that if you have extremely complex business logic in your triggers,
triggers might be better because they are executed in a defined order. But
for something like this, I fail to see how it makes things easier rather
than harder.

Best Wishes,
Chris Travers

In response to

Responses

Browse pgsql-announce by date

  From Date Subject
Next Message Eric B.Ridge 2004-01-24 07:44:12 Re: Touch row ?
Previous Message Chris Travers 2004-01-24 03:27:23 Re: Touch row ?

Browse pgsql-general by date

  From Date Subject
Next Message Eric B.Ridge 2004-01-24 07:44:12 Re: Touch row ?
Previous Message Dan Langille 2004-01-24 05:32:06 Re: LIVE Coverage of LinuxWorld Conference & Expo