Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 61B09476B7C for ; Fri, 6 Dec 2002 18:24:37 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id 8E990476549 for ; Fri, 6 Dec 2002 18:22:31 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2270318; Fri, 06 Dec 2002 15:22:18 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Bruce Momjian , Jean-Luc Lachance Subject: Re: Rules/Trigges Trade-offs Date: Fri, 6 Dec 2002 15:25:49 -0800 X-Mailer: KMail [version 1.4] Cc: pgsql-sql References: <200212061634.gB6GYbt02565@candle.pha.pa.us> In-Reply-To: <200212061634.gB6GYbt02565@candle.pha.pa.us> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200212061525.49284.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200212/84 X-Sequence-Number: 10672 Bruce, Richard, > Triggers are mostly for testing/modifying the row being > inserted/updated, while rules are better for affecting other rows or > other tables. Hmmm. Thought that there were also some other criteria: 1) Rules can't use indexes to do their processing, so Rules which query lar= ge=20 secondary tables can be a bad idea (maybe this has changed?) 2) Only Rules can "DO INSTEAD"; thus, only Rules are good for defining=20 Read/Write views. 3) There are no AFTER Rules, making, for example, a rule with a table check= on=20 the new data impractical, so you'd want to use Triggers or Constraints etc. There are, IMHO, some things Rules are better for, and some things Triggers= =20 are better for. I tend to use all Triggers except for updatable views,=20 simply because using a mix of Rules and Triggers can be very hard to keep= =20 track of, but YMMV. --=20 -Josh Berkus Aglio Database Solutions San Francisco