Re: Trigger vs Rule - Mailing list pgsql-performance

From Niklas Johansson
Subject Re: Trigger vs Rule
Date
Msg-id 2EE594DC-5F83-4381-9045-CB2A10180023@tele2.se
Whole thread Raw
In response to Trigger vs Rule  (Ключников А.С. <alexs@analytic.mv.ru>)
Responses Re: Trigger vs Rule
List pgsql-performance
On 2 apr 2006, at 10.31, Ключников А.С. wrote:
> What is faster?
> One trigger with 1000 ELSE IF
> Or 1000 rules

Faster to write and easier to maintain would be to write a trigger
function in pl/pgsql which executes the right function dynamically:

CREATE OR REPLACE FUNCTION exec_device_type() RETURNS trigger AS $$
    EXECUTE "SELECT device_type" || OLD.type || "(OLD.id)";
$$ LANGUAGE plpgsql;

Best would probably be to refactor your device_typeN() functions into
one, that would take N as an argument.


Sincerely,

Niklas Johansson





pgsql-performance by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: index not used again
Next
From: Josh Berkus
Date:
Subject: Re: Query using SeqScan instead of IndexScan