Re: Performance issues on FK Triggers after replacing a primary column

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Per Kaminsky <per(dot)kaminsky(at)hawk-intech(dot)com>
Cc: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Performance issues on FK Triggers after replacing a primary column
Date: 2022-03-28 14:07:06
Message-ID: 704027.1648476426@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Per Kaminsky <per(dot)kaminsky(at)hawk-intech(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Laurenz Albe 2022-03-28 15:31:57 Re: Will using subtransactions will come back to bite me?
Previous Message Philippe Doussot 2022-03-28 09:42:22 Re: Leading comments and client applications