pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Per Kaminsky <per.kaminsky@hawk-intech.com>
Cc: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: 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 10:07:06 -0400
Message-ID: <704027.1648476426@sss.pgh.pa.us> (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>

Per Kaminsky <per.kaminsky@hawk-intech.com> writes:
> # ('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',)

Sure looks like B_shiftinstanceid_fkey and B_to_A_fkey are running
seq scans for lack of any matching index.

> 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 to make a rollback on any problem without causing an abnormal data state regarding the program.

Hmm, are you dropping and re-adding the reference-side indexes as part of
the same transaction that is doing this?  I'm too short of caffeine to
recall details, but I think there are cases where a newly-made index
cannot be used right away.

			regards, tom lane





view thread (13+ messages)  latest in thread

Message-ID: <704027.1648476426@sss.pgh.pa.us>
Permalink:  ../704027.1648476426@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/704027.1648476426@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, per.kaminsky@hawk-intech.com, adrian.klaver@aklaver.com
  Subject: Re: Performance issues on FK Triggers after replacing a primary column
  In-Reply-To: <704027.1648476426@sss.pgh.pa.us>
  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> <704027.1648476426@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