pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Per Kaminsky <per.kaminsky@hawk-intech.com>
To: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: Performance issues on FK Triggers after replacing a primary column
Date: Mon, 28 Mar 2022 08:41:42 -0700
Message-ID: <733c2f32-e808-9024-2332-b0a972ac0bb0@aklaver.com> (raw)
In-Reply-To: <DB8PR09MB39132BA118F119400CD69C8FD81D9@DB8PR09MB3913.eurprd09.prod.outlook.com>
References: <DB8PR09MB3913300D0A5150D499048FA8D81C9@DB8PR09MB3913.eurprd09.prod.outlook.com>
	<8ed0c2ae-8a35-2628-4b41-68f9cb734297@aklaver.com>
	<DB8PR09MB3913EC4DBBDFAC619D119C93D81D9@DB8PR09MB3913.eurprd09.prod.outlook.com>
	<DB8PR09MB39132BA118F119400CD69C8FD81D9@DB8PR09MB3913.eurprd09.prod.outlook.com>

On 3/28/22 00:22, Per Kaminsky wrote:
> Sorry, i forgot to add the following:
> 
> Explain / Analyze for the last "update type on B" call, normally there 
> the table has million of rows but i removed most of them since otherwise 
> it would not finish sometime soon:
> 
>     ('Update on B (cost=0.00..71.50 rows=1000 width=244) (actual
>     time=18.015..18.015 rows=0 loops=1)',)
>     ('  Buffers: shared hit=26141 read=21 dirtied=77 written=54',)
>     ('  ->  Seq Scan on B (cost=0.00..71.50 rows=1000 width=244) (actual
>     time=0.102..0.536 rows=1000 loops=1)',)
>     ('        Filter: ((type IS NULL) AND (firmid = 1))',)
>     ('        Buffers: shared hit=59',)
>     ('Planning Time: 0.430 ms',)
>     # ('Trigger for constraint B_firmid_fkey: time=25.592 calls=1000',)
>     # ('Trigger for constraint B_type_fkey: time=14.899 calls=1000',)
>     # ('Trigger for constraint B_userid_fkey: time=16.146 calls=1000',)
>     # ('Trigger for constraint B_version_fkey: time=11.285 calls=1000',)
>     # ('Trigger for constraint B_common_fkey: time=7.913 calls=1000',)
>     # ('Trigger for constraint B_shiftinstanceid_fkey: time=8543.369
>     calls=1000',)
>     ('Trigger for constraint B_to_A_fkey: time=27246.413 calls=1000',)
>     ('Execution Time: 35884.978 ms',)
> 
> The tables have Index on each other. The vacuum can not be called, since 
> all those table modifications are part of one big transaction to be able 

Analyze can be run by itself in the transaction. As Tom said I am not 
seeing any information about indexes on the tables(s). Also, which one 
of the tables you showed is the temporary one or was that not shown?


> to make a rollback on any problem without causing an abnormal data state 
> regarding the program.
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





view thread (13+ messages)  latest in thread

Message-ID: <733c2f32-e808-9024-2332-b0a972ac0bb0@aklaver.com>
Permalink:  ../733c2f32-e808-9024-2332-b0a972ac0bb0@aklaver.com/
Also on:    postgresql.org/message-id/733c2f32-e808-9024-2332-b0a972ac0bb0@aklaver.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 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: adrian.klaver@aklaver.com, per.kaminsky@hawk-intech.com
  Subject: Re: Performance issues on FK Triggers after replacing a primary column
  In-Reply-To: <733c2f32-e808-9024-2332-b0a972ac0bb0@aklaver.com>
  References: <DB8PR09MB3913300D0A5150D499048FA8D81C9@DB8PR09MB3913.eurprd09.prod.outlook.com> <8ed0c2ae-8a35-2628-4b41-68f9cb734297@aklaver.com> <DB8PR09MB3913EC4DBBDFAC619D119C93D81D9@DB8PR09MB3913.eurprd09.prod.outlook.com> <DB8PR09MB39132BA118F119400CD69C8FD81D9@DB8PR09MB3913.eurprd09.prod.outlook.com> <733c2f32-e808-9024-2332-b0a972ac0bb0@aklaver.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