Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C70EE475DC0 for ; Fri, 6 Dec 2002 18:30:20 -0500 (EST) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by postgresql.org (Postfix) with ESMTP id 6D45947629B for ; Fri, 6 Dec 2002 18:30:18 -0500 (EST) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.10.1) id gB6NUDl20018; Fri, 6 Dec 2002 18:30:13 -0500 (EST) From: Bruce Momjian Message-Id: <200212062330.gB6NUDl20018@candle.pha.pa.us> Subject: Re: Rules/Trigges Trade-offs In-Reply-To: <200212061525.49284.josh@agliodbs.com> To: josh@agliodbs.com Date: Fri, 6 Dec 2002 18:30:13 -0500 (EST) Cc: Jean-Luc Lachance , pgsql-sql X-Mailer: ELM [version 2.4ME+ PL99 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200212/85 X-Sequence-Number: 10673 Josh Berkus wrote: > > 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 large > secondary tables can be a bad idea (maybe this has changed?) I don't think this is true. Rewrite is before optimizer so it should be optimized just the same. > > 2) Only Rules can "DO INSTEAD"; thus, only Rules are good for defining > Read/Write views. True. > 3) There are no AFTER Rules, making, for example, a rule with a table check on > the new data impractical, so you'd want to use Triggers or Constraints We have changed ordering in 7.3 where I think INSERT rules are _after_ the insert. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073