pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ken Tanzer <ken.tanzer@gmail.com>
Cc: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: basti <mailinglist@unix-solution.de>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Conditional INSERT
Date: Fri, 15 Mar 2019 21:43:06 -0400
Message-ID: <21578.1552700586@sss.pgh.pa.us> (raw)
In-Reply-To: <CAD3a31WC87GcxV=_cJwzoppCjzAe61CZh5XDf5J-xOSi8m4sXw@mail.gmail.com>
References: <68951fae-3281-c9ad-09b7-205e0bb1c5ae@unix-solution.de>
	<CACxu=vKcVZdjsmMQyGf2tAcVAt8vyz2X1b+ynPb=_==AATjbVA@mail.gmail.com>
	<CAHOFxGr3WCD1Kb0mL8aXiRHyYpOaV98uzF_pcJA_ALF4V0qhjA@mail.gmail.com>
	<1ebb57da-c34b-6581-ea33-bdf78f6990f8@unix-solution.de>
	<53dc55ae-506f-2aed-ea80-50f0978837ab@aklaver.com>
	<CAD3a31U5YB8vd4CyKWrbuZoqgiE58SCdOUck6ju9b_yvrZ9Daw@mail.gmail.com>
	<b6316de2-1072-0724-7149-7e0ea4feaaf9@aklaver.com>
	<CAD3a31WC87GcxV=_cJwzoppCjzAe61CZh5XDf5J-xOSi8m4sXw@mail.gmail.com>

Ken Tanzer <ken.tanzer@gmail.com> writes:
> OK, and thanks for the info. I've gleaned that rules are not "deprecated"
> in the sense that they are slated for removal, but they are rather
> discouraged.  Since that's the case, wouldn't it make sense to warn users
> about this?

There's no plan to remove them, but we do encourage people to think of
triggers first.  That's why the triggers chapter appears first, and why
the "rules vs. triggers" section doesn't really read as evenhanded
(to me anyway).

> In the section on "Rules vs. Triggers" (41.7), it doesn't even hint at
> this, and even says:
> *"For the things that can be implemented by both, which is best depends on
> the usage of the database."*

You're ignoring the sentence immediately before that, which is

    Writing such triggers is often easier than writing rules, particularly
    if complex logic is required to perform the update.

as well as the one at the end of its (short) paragraph:

    However, the trigger approach is conceptually far simpler than the
    rule approach, and is easier for novices to get right.

The only case where we're really encouraging people to use rules is
where the overhead of a trigger is unacceptable.  Even then, this
whole section is written thinking of per-row triggers.  The performance
tradeoffs would likely be quite different if using a per-statement trigger
with transition tables.  But that's a very new feature, and I don't think
anyone's done serious performance comparisons of that vs. rules.

			regards, tom lane




view thread (36+ messages)

Message-ID: <21578.1552700586@sss.pgh.pa.us>
Permalink:  ../21578.1552700586@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/21578.1552700586@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, ken.tanzer@gmail.com, adrian.klaver@aklaver.com, mailinglist@unix-solution.de
  Subject: Re: Conditional INSERT
  In-Reply-To: <21578.1552700586@sss.pgh.pa.us>
  References: <68951fae-3281-c9ad-09b7-205e0bb1c5ae@unix-solution.de> <CACxu=vKcVZdjsmMQyGf2tAcVAt8vyz2X1b+ynPb=_==AATjbVA@mail.gmail.com> <CAHOFxGr3WCD1Kb0mL8aXiRHyYpOaV98uzF_pcJA_ALF4V0qhjA@mail.gmail.com> <1ebb57da-c34b-6581-ea33-bdf78f6990f8@unix-solution.de> <53dc55ae-506f-2aed-ea80-50f0978837ab@aklaver.com> <CAD3a31U5YB8vd4CyKWrbuZoqgiE58SCdOUck6ju9b_yvrZ9Daw@mail.gmail.com> <b6316de2-1072-0724-7149-7e0ea4feaaf9@aklaver.com> <CAD3a31WC87GcxV=_cJwzoppCjzAe61CZh5XDf5J-xOSi8m4sXw@mail.gmail.com> <21578.1552700586@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox