Re: Attempting to delete excess rows from table with BATCH DELETE

From: Greg Sabino Mullane <htamfids(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: Gus Spier <gus(dot)spier(at)gmail(dot)com>, pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Attempting to delete excess rows from table with BATCH DELETE
Date: 2026-01-28 15:38:53
Message-ID: CAKAnmmLhL-kPtMy9+rpwbaOpEi5AsidXzO8_z5-n=iOAG+1ZUA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Jan 27, 2026 at 10:31 PM David G. Johnston <
david(dot)g(dot)johnston(at)gmail(dot)com> wrote:

> Strongly encourage you to try to accomplish your goal without any delete
> commands at that scale that causes vacuuming. Can you just create an empty
> copy and load the data to keep into it then point at the newly filled
> database? Truncate is OK.
>

This is really the best solution, especially if most of the rows are > 75
days old. This removes 100% of your bloat, allows you to keep the old data
around in case something goes wrong, reduces WAL compared to massive
deletes, and removes the need to mess with autovacuum.

Cheers,
Greg

--
Crunchy Data - https://www.crunchydata.com
Enterprise Postgres Software Products & Tech Support

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gus Spier 2026-01-28 15:39:00 Re: Attempting to delete excess rows from table with BATCH DELETE
Previous Message Ron Johnson 2026-01-28 15:02:17 Re: Attempting to delete excess rows from table with BATCH DELETE