Insert fails. TRUNCATE process takes long

From: Bart Jonk <bart(dot)jonk(at)voys(dot)nl>
To: pgsql-novice(at)lists(dot)postgresql(dot)org
Subject: Insert fails. TRUNCATE process takes long
Date: 2025-01-22 10:00:36
Message-ID: CANEeCvxFYeU+FZJ1_KVi9PMMiW65=NpD32P_0NzP1i+V_VRb6g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Last night we had a scheduled script that was ended by `statement_timeout`
setting. It took hours instead of seconds. The script is normally inserting
1M records (1.028.563), in seconds.
insert happens after a truncate of the table.

This morning we tried restarting the script. checked for locks first. No
locks, however same issue. Process hangs.

We rebooted the db server. and now did two things.

1) for safety we tried to truncate the table again (while already empty,
confirmed with select *)

The truncate returned with success (according to ODBC), however, the
process keep running:
[image: image.png]

2) in spite of that. we decided to restart the script. insert succeeded.

Not sure what happened / is happening, It's very hard to find an
explanation on-line.

What can we do to prevent this happening again?

Kind regards,

Bart Jonk

Voys

You can call me on +31 6 1008 4361

Or email me at bart(dot)jonk(at)voys(dot)nl

Browse pgsql-novice by date

  From Date Subject
Next Message Pedro Moraes 2025-01-27 13:18:29 Insert on conflict do update fails with duplicate rows - there are no duplicates
Previous Message Bruce Momjian 2025-01-18 19:07:24 Re: PG-15 - Format problems after jump migration from 9-4 to 15