Re: Need an idea to operate massive delete operation on big size table. - Mailing list pgsql-admin

From Laurenz Albe
Subject Re: Need an idea to operate massive delete operation on big size table.
Date
Msg-id 82cbc03d6bae358db66430f5518abd6b1a683571.camel@cybertec.at
Whole thread Raw
In response to Need an idea to operate massive delete operation on big size table.  (Gambhir Singh <gambhir.singh05@gmail.com>)
Responses Re: Need an idea to operate massive delete operation on big size table.
List pgsql-admin
On Wed, 2025-01-15 at 20:23 +0530, Gambhir Singh wrote:
> I received a request from a client to delete duplicate records from a table which is very large in size. 
>
> Delete queries (~2 Billion) are provided via file, and we have to execute that file in DB.
> Last time it lasted for two days. I feel there must be another way to delete records in an efficient manner
>
> This kind of activity they do every month.

I don't think there is a better way - except perhaps to create a new copy of
the table and copy the surviving rows to the new table.  Than may win if you
delete a majority of the rows.

For the future, you could consider not adding the duplicate rows rather than
deleting them.  Perhaps a constraint that prevents the duplicates can help.

Yours,
Laurenz Albe



pgsql-admin by date:

Previous
From: Mohit Mishra
Date:
Subject: Re: Move datapath
Next
From: Alex Balashov
Date:
Subject: Re: Need an idea to operate massive delete operation on big size table.