BUG #18620: Problem: Slow Delete Operation - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #18620: Problem: Slow Delete Operation
Date
Msg-id 18620-69d2c91afdcf3f86@postgresql.org
Whole thread Raw
Responses Re: BUG #18620: Problem: Slow Delete Operation
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      18620
Logged by:          gowtham
Email address:      gowthamraj.kennedykannan@chainsys.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.


pgsql-bugs by date:

Previous
From: Greg Sabino Mullane
Date:
Subject: logical replication walsender loop preventing a clean shutdown
Next
From: "David G. Johnston"
Date:
Subject: Re: BUG #18620: Problem: Slow Delete Operation