Re: Batch process - Mailing list pgsql-general

From Adrian Klaver
Subject Re: Batch process
Date
Msg-id 375897a0-fbbb-8712-8164-8fbd3cab074a@aklaver.com
Whole thread Raw
In response to Batch process  (Rama Krishnan <raghuldrag@gmail.com>)
Responses Re: Batch process  (Rama Krishnan <raghuldrag@gmail.com>)
List pgsql-general
On 7/19/22 22:08, Rama Krishnan wrote:
> Hi All,
> 
> I am doing purge activity my sales table contains 5M records I am going 
> to delete more than 1 year data (which was 3M) records so it was running 
> more so I want to do batch wise deletion through plsql
> 
> 
> 
> 
>   created or replace function data_purge() returns void as$$
> Declare
> Begin
> Drop table test_old;
> Create table test_old as select * from sales where bill_date<now() 
> -interval '1 year';
> 
> Delete table sales where sales_id in (select sales_id from test_old;
> 
> End;
> $$ language plpgsql;
> 
> 
> Kindly guide me
> 

This looks like a case, going forward for partitioning:

https://www.postgresql.org/docs/14/ddl-partitioning.html


-- 
Adrian Klaver
adrian.klaver@aklaver.com



pgsql-general by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: postgis
Next
From: Rama Krishnan
Date:
Subject: Re: Batch process