Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id C2C09476428 for ; Thu, 16 May 2002 11:12:48 -0400 (EDT) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id 0AF024763BE for ; Thu, 16 May 2002 11:12:23 -0400 (EDT) Received: from [63.195.55.98] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.5.9) with HTTP id 1461719; Thu, 16 May 2002 08:12:26 -0700 From: "Josh Berkus" Subject: Re: Rules and Triggers To: Ludwig Lim , pgsql-sql@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.3.5.9 Date: Thu, 16 May 2002 08:12:26 -0700 Message-ID: In-Reply-To: <20020516045940.41862.qmail@web20402.mail.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Archive-Number: 200205/161 X-Sequence-Number: 7797 Ludwig, > I tried converting the rule to function & trigger > and it reported that it used an Index scan given the > same INSERT statement. > > I was wondering why the rule used sequentail scan > and the equivalent function trigger used index scan. This is one of the documented differences between rules and triggers (at least, I've seen it in the documentation *somewhere*). I can't tell you "why", though ... hopefully Tom or Bruce will speak to that. For myself, I use triggers for most things, and rules just for updatable views. Aside for index efficiency, rules are a Postgres-only thing, whereas several RDBMS's support triggers. Gives me marginally better portability. -Josh Berkus