X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 9384A11F8AE5 for ; Mon, 3 Apr 2006 06:17:47 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 60366-03 for ; Mon, 3 Apr 2006 06:17:44 -0300 (ADT) Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 3456711F8A4A for ; Mon, 3 Apr 2006 06:17:43 -0300 (ADT) Received: from analytic.local (analytic.yun5.7winds.ru [81.176.142.130]) by svr4.postgresql.org (Postfix) with ESMTP id 057EC5AF88D for ; Mon, 3 Apr 2006 09:17:42 +0000 (GMT) Received: from analytic.local (localhost [127.0.0.1]) by analytic.local (8.13.6/8.13.4) with ESMTP id k339HaTY001293 for ; Mon, 3 Apr 2006 13:17:36 +0400 (MSD) (envelope-from alexs@analytic.local) Received: (from alexs@localhost) by analytic.local (8.13.6/8.13.1/Submit) id k339HaXU001292 for pgsql-performance@postgresql.org; Mon, 3 Apr 2006 13:17:36 +0400 (MSD) (envelope-from alexs) Date: Mon, 3 Apr 2006 13:17:36 +0400 From: =?utf-8?B?0JrQu9GO0YfQvdC40LrQvtCyINCQLtChLg==?= To: pgsql-performance@postgresql.org Subject: Re: Trigger vs Rule Message-ID: <20060403091736.GB366@mail.analytic.mv.ru> Mail-Followup-To: pgsql-performance@postgresql.org References: <20060402083149.GA62166@mail.analytic.mv.ru> <2EE594DC-5F83-4381-9045-CB2A10180023@tele2.se> <5DEF8AEF-9FBD-4C6E-88BD-FA90CB1BDF31@tele2.se> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5DEF8AEF-9FBD-4C6E-88BD-FA90CB1BDF31@tele2.se> User-Agent: Mutt/1.4.2.1i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] X-Spam-Score: 0.12 X-Spam-Level: X-Archive-Number: 200604/20 X-Sequence-Number: 18104 * Niklas Johansson [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