From: Ключников А.С. <alexs@analytic.mv.ru>
To: pgsql-performance@postgresql.org
Subject: Trigger vs Rule
Date: Sun, 2 Apr 2006 12:31:49 +0400
Message-ID: <20060402083149.GA62166@mail.analytic.mv.ru> (raw)
Hi all.
There are two tables:
create table device_types (
id int,
name varchar
);
about 1000 rows
create table devices (
id int,
type int REFERENCES device_types(id),
name varchar,
data float
);
about 200000 rows
And about 1000 functions:
create function device_type1(int) returns ..
create function device_type2(int) returns ..
...
create function device_type1000(int) returns ..
What is faster?
One trigger with 1000 ELSE IF
if old.type=1 then
select device_type1(old.id);
else if old.type=2 then
select device_type2(old.id);
...
else if old.type=1000 then
select device_type1000(old.id);
end if;
Or 1000 rules
create rule device_type1 AS ON update to devices
where old.type=1
DO select device_type1(old.id);
create rule device_type2 AS ON update to devices
where old.type=2
DO select device_type2(old.id);
...
create rule device_type1000 AS ON update to devices
where old.type=1000
DO select device_type1000(old.id);
thx.
--
С уважением,
Ключников А.С.
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 using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: alexs@analytic.mv.ru
Subject: Re: Trigger vs Rule
In-Reply-To: <20060402083149.GA62166@mail.analytic.mv.ru>
* 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