Re: Batch process

From: Rama Krishnan <raghuldrag(at)gmail(dot)com>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Batch process
Date: 2022-07-20 15:26:26
Message-ID: CAJWX+ENuYcKuBo8X122wAKUoS1BCiYC8fprjxYgK54fEo09Hmg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi Adrian,

Thanks for the update.

Is it possible to achieve 10000 records deletion on every iteration because
my original table contains 5M records during the deletion process it
consumes more cpu and resources.

On Wed, 20 Jul, 2022, 20:37 Adrian Klaver, <adrian(dot)klaver(at)aklaver(dot)com>
wrote:

> 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(dot)klaver(at)aklaver(dot)com
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rob Sargent 2022-07-20 15:30:42 Re: Batch process
Previous Message Adrian Klaver 2022-07-20 15:07:54 Re: Batch process