Re: How many records to delete ? - Mailing list pgsql-general

From John R Pierce
Subject Re: How many records to delete ?
Date
Msg-id 4B4580BC.8010306@hogranch.com
Whole thread Raw
In response to How many records to delete ?  (shulkae <shulkae@gmail.com>)
List pgsql-general
shulkae wrote:
> I am writing a shell script which runs as a cron entry. The objective
> is to delete older records from postgresql DB.
>
> I have thousands of records. What is the optimum number of records to
> delete in one delete command
>

as many as you need to,

    DELETE FROM yourtable AS t
        WHERE CURRENT_DATE - t.recorddate < INTERVAL '90 days';

or whatever.   pooof, all records over that given parameter are deleted,
about as efficiently as can be.   of course, as always, the space
doesn't get reclaimed until that table is vacuumed.



pgsql-general by date:

Previous
From: Rikard Bosnjakovic
Date:
Subject: Re: How many records to delete ?
Next
From: Yan Cheng Cheok
Date:
Subject: Use C++ to iterate integer array returned from stored procedure