Batch process

From: Rama Krishnan <raghuldrag(at)gmail(dot)com>
To: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Batch process
Date: 2022-07-20 05:08:29
Message-ID: CAJWX+ENJm8tsZ2y9z075w-4Vbtv4GQaLOQpVb8b-VYiOea1oPw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Karthik K L V 2022-07-20 05:42:33 Re: Migrating from Oracle - Implicit Casting Issue
Previous Message Marc Millas 2022-07-20 03:07:24 Re: postgis