pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tobias Gierke <tobias.gierke@code-sourcery.de>
To: David Rowley <dgrowleyml@gmail.com>
To: Justin Pryzby <pryzby@telsasoft.com>
Cc: pgsql-performance <pgsql-performance@postgresql.org>
Subject: Re: Linear slow-down while inserting into a table with an ON INSERT trigger ?
Date: Sun, 18 Jul 2021 09:25:19 +0200
Message-ID: <9f2df5fb-50a4-fefd-810a-d3b915717190@code-sourcery.de> (raw)
In-Reply-To: <CAApHDvr-kFAmOihG1FxVZfgdV_e5TR8cU3n+QPkYwJ8XqmA4YQ@mail.gmail.com>
References: <62070f97-13e7-df73-bed1-f8e48c12bf2d@code-sourcery.de>
	<20210717044026.GA19498@telsasoft.com>
	<CAApHDvr-kFAmOihG1FxVZfgdV_e5TR8cU3n+QPkYwJ8XqmA4YQ@mail.gmail.com>

Great idea ! This brought the time per INSERT into the parent table down 
to a consistent ~0.065ms again (compared to 0.05ms when completely 
removing the trigger, so penalty for the trigger is roughly ~20%).

> On Sat, 17 Jul 2021 at 16:40, Justin Pryzby <pryzby@telsasoft.com> wrote:
>> You could run a single UPDATE rather than 30k triggers.
>> Or switch to an INSERT on the table, with an index on it, and call
>> max(last_parent_table_change) from whatever needs to ingest it.  And prune the
>> old entries and vacuum it outside the transaction.  Maybe someone else will
>> have a better suggestion.
> Maybe just change the UPDATE statement to:
>
> UPDATE data_sync SET last_parent_table_change=CURRENT_TIMESTAMP WHERE
> last_parent_table_change <> CURRENT_TIMESTAMP;
>
> That should reduce the number of actual updates to 1 per transaction.
>
> David





view thread (10+ messages)  latest in thread

Message-ID: <9f2df5fb-50a4-fefd-810a-d3b915717190@code-sourcery.de>
Permalink:  ../9f2df5fb-50a4-fefd-810a-d3b915717190@code-sourcery.de/
Also on:    postgresql.org/message-id/9f2df5fb-50a4-fefd-810a-d3b915717190@code-sourcery.de

 · 

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-performance@postgresql.org
  Cc: tobias.gierke@code-sourcery.de, dgrowleyml@gmail.com, pryzby@telsasoft.com
  Subject: Re: Linear slow-down while inserting into a table with an ON INSERT trigger ?
  In-Reply-To: <9f2df5fb-50a4-fefd-810a-d3b915717190@code-sourcery.de>

* 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