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>
To: Tom Lane <tgl@sss.pgh.pa.us>
Subject: Re: Performance issues on FK Triggers after replacing a primary column
Date: Mon, 28 Mar 2022 08:59:35 -0700
Message-ID: <524b0b1c-d351-0a9f-01e5-1f60eeda5fe8@aklaver.com> (raw)
In-Reply-To: <DB8PR09MB3913F47BBADD1A6378726565D81D9@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>
	<733c2f32-e808-9024-2332-b0a972ac0bb0@aklaver.com>
	<DB8PR09MB3913F47BBADD1A6378726565D81D9@DB8PR09MB3913.eurprd09.prod.outlook.com>

On 3/28/22 08:47, Per Kaminsky wrote:
> The tables have Index to each other on each foreign key. The index 
> itself was not touched though, and a remove/recreate did not help. Could 
> it be possible, that when the PK and FK values are replaced the Index is 
> not (immediately) updated and thus cannot be used?

Have you tried an ANALYZE on "A" AND "B" after?:

UPDATE "A" SET id = id_temp;

As to the index not immediately updating, I don't know.


> 
> The temporary table is not shown. It is created to insert the new values 
> from file, then used to update the correct table with the new values, 
> and then removed, it has no connection (FK or something else) to any 
> other table.
> 

So that is the '// fill id_temp with new IDs' part?


-- 
Adrian Klaver
adrian.klaver@aklaver.com





view thread (13+ messages)  latest in thread

Message-ID: <524b0b1c-d351-0a9f-01e5-1f60eeda5fe8@aklaver.com>
Permalink:  ../524b0b1c-d351-0a9f-01e5-1f60eeda5fe8@aklaver.com/
Also on:    postgresql.org/message-id/524b0b1c-d351-0a9f-01e5-1f60eeda5fe8@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, tgl@sss.pgh.pa.us
  Subject: Re: Performance issues on FK Triggers after replacing a primary column
  In-Reply-To: <524b0b1c-d351-0a9f-01e5-1f60eeda5fe8@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> <DB8PR09MB3913F47BBADD1A6378726565D81D9@DB8PR09MB3913.eurprd09.prod.outlook.com> <524b0b1c-d351-0a9f-01e5-1f60eeda5fe8@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