pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Pg Hackers <pgsql-hackers@postgresql.org>
Cc: Simon Riggs <simon@2ndquadrant.com>
Subject: Re: FOR EACH ROW triggers on partitioned tables
Date: Fri, 16 Feb 2018 15:30:15 -0500
Message-ID: <812dce79-717e-6905-afee-8c3cb27aab1a@2ndquadrant.com> (raw)
In-Reply-To: <20180215215525.3anqmydfi6pfrmvf@alvherre.pgsql>
References: <20180215215525.3anqmydfi6pfrmvf@alvherre.pgsql>

On 2/15/18 16:55, Alvaro Herrera wrote:
> Amit Langote wrote:
>> Do you mean to fire these triggers only if the parent table (not a child
>> table/partition) is addressed in the DML, right?  If the table directly
>> addressed in the DML is a partition whose parent has a row-level trigger,
>> then that trigger should not get fired I suppose.
> 
> No, I think that would be strange and cause data inconsistencies.
> Inserting directly into the partition is seen as a performance
> optimization (compared to inserted into the partitioned table), so we
> don't get to skip firing the triggers defined on the parent because the
> behavior would become different.  In other words, the performance
> optimization breaks the database.
> 
> Example: suppose the trigger is used to maintain an audit record trail.

Although this situation could probably be addressed by not giving
permission to write directly into the partitions, I can't think of an
example where one would want a trigger that is only fired when writing
into the partition root rather than into the partition directly.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services




view thread (39+ messages)  latest in thread

Message-ID: <812dce79-717e-6905-afee-8c3cb27aab1a@2ndquadrant.com>
Permalink:  ../812dce79-717e-6905-afee-8c3cb27aab1a@2ndquadrant.com/
Also on:    postgresql.org/message-id/812dce79-717e-6905-afee-8c3cb27aab1a@2ndquadrant.com

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: peter.eisentraut@2ndquadrant.com, alvherre@alvh.no-ip.org, Langote_Amit_f8@lab.ntt.co.jp, robertmhaas@gmail.com, simon@2ndquadrant.com
  Subject: Re: FOR EACH ROW triggers on partitioned tables
  In-Reply-To: <812dce79-717e-6905-afee-8c3cb27aab1a@2ndquadrant.com>

* 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