Re: Batch process - Mailing list pgsql-general

From Ron
Subject Re: Batch process
Date
Msg-id 1f2e957b-dbfc-5c17-2abd-77a944a6786c@gmail.com
Whole thread Raw
In response to Re: Batch process  (Adrian Klaver <adrian.klaver@aklaver.com>)
Responses Re: Batch process  (Adrian Klaver <adrian.klaver@aklaver.com>)
List pgsql-general
But the first thing he does is drop test_old.

On 7/20/22 09:52, Adrian Klaver wrote:
> On 7/20/22 01:28, Ron wrote:
>> On 7/20/22 00: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
>>
>> Why not just DELETE FROM sales WHERE bill_date<NOW() -INTERVAL '1 year';?
>>
>
> Because it looks like the OP is saving the old records in test_old.
>
>

-- 
Angular momentum makes the world go 'round.



pgsql-general by date:

Previous
From: Thierry Henrio
Date:
Subject: plan for function returning table combined with condition
Next
From: Adrian Klaver
Date:
Subject: Re: Batch process