Re: How many records to delete ?

From: John R Pierce <pierce(at)hogranch(dot)com>
To: shulkae <shulkae(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How many records to delete ?
Date: 2010-01-07 06:35:40
Message-ID: 4B4580BC.8010306@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Yan Cheng Cheok 2010-01-07 06:44:44 Use C++ to iterate integer array returned from stored procedure
Previous Message Rikard Bosnjakovic 2010-01-07 06:20:38 Re: How many records to delete ?