pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ключников А.С. <alexs@analytic.mv.ru>
To: pgsql-performance@postgresql.org
Subject: Re: Trigger vs Rule
Date: Mon, 3 Apr 2006 13:17:36 +0400
Message-ID: <20060403091736.GB366@mail.analytic.mv.ru> (raw)
In-Reply-To: <5DEF8AEF-9FBD-4C6E-88BD-FA90CB1BDF31@tele2.se>
References: <20060402083149.GA62166@mail.analytic.mv.ru>
	<2EE594DC-5F83-4381-9045-CB2A10180023@tele2.se>
	<5DEF8AEF-9FBD-4C6E-88BD-FA90CB1BDF31@tele2.se>

* Niklas Johansson <spot@tele2.se> [2006-04-03 11:04:25 +0200]:

> 
> On 2 apr 2006, at 23.08, Niklas Johansson wrote:
> 
> >CREATE OR REPLACE FUNCTION exec_device_type() RETURNS trigger AS $$
> >	EXECUTE "SELECT device_type" || OLD.type || "(OLD.id)";
> >$$ LANGUAGE plpgsql;
> 
> 
> Sorry, I was bitten by the bedbug there: a plpgsql function needs a  
> little more than that to be functional :)
> 
> CREATE OR REPLACE FUNCTION exec_device_type() RETURNS trigger AS $$
> BEGIN
> 	EXECUTE 'SELECT device_type' || OLD.type || '(OLD.id)';
> 	RETURN NEW/OLD/NULL; -- Depending on your application.
> END;
> $$ LANGUAGE plpgsql;
> 
> But really, you should consider reworking your schema structure.  
> Having a thousand functions doing almost the same thing is neither  
> efficient, nor maintainable.
Things are very diferent. 
For many types functions not needed, jast update.

I.e. This is a way One trigger with ~1000 else if.
Here was a diametral opinion.  
> 
> 
> 
> Sincerely,
> 
> Niklas Johansson
> 
> 
> 
> 

-- 
С уважением,
Ключников А.С.
Ведущий инженер ПРП "Аналитприбор"
432030 г.Ульяновск, а/я 3117
тел./факс +7 (8422) 43-44-78
mailto: alexs@analytic.mv.ru



view thread (4+ messages)

Message-ID: <20060403091736.GB366@mail.analytic.mv.ru>
Permalink:  ../20060403091736.GB366@mail.analytic.mv.ru/
Also on:    postgresql.org/message-id/20060403091736.GB366@mail.analytic.mv.ru

 · 

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 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: <20060403091736.GB366@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