BUG #18620: Problem: Slow Delete Operation

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: gowthamraj(dot)kennedykannan(at)chainsys(dot)com
Subject: BUG #18620: Problem: Slow Delete Operation
Date: 2024-09-16 18:54:50
Message-ID: 18620-69d2c91afdcf3f86@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 18620
Logged by: gowtham
Email address: gowthamraj(dot)kennedykannan(at)chainsys(dot)com
PostgreSQL version: 15.6
Operating system: Windows
Description:

Problem: Slow Delete Operation

Issue: Deleting 4000 records from a parent table is taking more than 1
hour.

Database Structure:
Parent Table: Contains primary keys, referenced by foreign keys in child
tables.
Child Tables: 3 tables, each having foreign key constraints linked to the
parent table's primary keys.
Data Size: All tables contain over a million records.
Indexing: Indexes have been created on all primary keys in both the parent
and child tables.

Tested Scenarios:
Index Rebuilding: Rebuilding indexes on both the parent and child tables did
not improve the delete performance.

Recreating Parent Table: Recreating the parent table with the same data and
constraints also did not resolve the slowness issue.

Foreign Key Removal: When the foreign key constraints were removed from the
child tables, deleting 4000 records from the parent table took only a few
seconds. This suggests the foreign key checks are causing the slowness.

Requirement:
Improve the performance of the delete operation without removing the foreign
key constraints.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Francesco Degrassi 2024-09-16 19:35:13 Leader backend hang on IPC/ParallelFinish when LWLock held at parallel query start
Previous Message Greg Sabino Mullane 2024-09-16 18:27:42 logical replication walsender loop preventing a clean shutdown