| From: | Ron <ronljohnsonjr(at)gmail(dot)com> |
|---|---|
| To: | pgsql-general(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Batch process |
| Date: | 2022-07-20 08:28:54 |
| Message-ID: | 5d0d0349-1e6f-3f8f-41cb-3d853712eff9@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
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';?
--
Angular momentum makes the world go 'round.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Sebastien Flaesch | 2022-07-20 09:15:29 | Re: Concurrent INSERT statements with RETURNING clause resetting SERIAL sequence |
| Previous Message | Ron | 2022-07-20 08:25:08 | Re: postgis |