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 5829D11F6C76 for ; Sun, 2 Apr 2006 05:32:00 -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 30999-08 for ; Sun, 2 Apr 2006 05:31:59 -0300 (ADT) Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 6120711F6C70 for ; Sun, 2 Apr 2006 05:31:58 -0300 (ADT) Received: from analytic.local (analytic.yun5.7winds.ru [81.176.142.130]) by svr4.postgresql.org (Postfix) with ESMTP id 235965AF678 for ; Sun, 2 Apr 2006 08:31:56 +0000 (GMT) Received: from analytic.local (localhost [127.0.0.1]) by analytic.local (8.13.6/8.13.4) with ESMTP id k328VnLB062264 for ; Sun, 2 Apr 2006 12:31:49 +0400 (MSD) (envelope-from alexs@analytic.local) Received: (from alexs@localhost) by analytic.local (8.13.6/8.13.1/Submit) id k328Vna7062263 for pgsql-performance@postgresql.org; Sun, 2 Apr 2006 12:31:49 +0400 (MSD) (envelope-from alexs) Date: Sun, 2 Apr 2006 12:31:49 +0400 From: =?utf-8?B?0JrQu9GO0YfQvdC40LrQvtCyINCQLtChLg==?= To: pgsql-performance@postgresql.org Subject: Trigger vs Rule Message-ID: <20060402083149.GA62166@mail.analytic.mv.ru> Mail-Followup-To: pgsql-performance@postgresql.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.4.2.1i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[none] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200604/10 X-Sequence-Number: 18094 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. -- С уважением, Ключников А.С.