Re: Chunk Delete

From: "Alexander Staubo" <alex(at)purefiction(dot)net>
To: "Abraham, Danny" <danny_abraham(at)bmc(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Chunk Delete
Date: 2007-11-15 10:52:46
Message-ID: 88daf38c0711150252l4a0d6962g8b6da8044c7ad0a2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 11/15/07, Abraham, Danny <danny_abraham(at)bmc(dot)com> wrote:
> In Oracle we erase 50,000 records using the following:
>
> Delete <table name> where <condition> and ROWNUM < 50000;
>
> Do we have such a feature in PG?

Just delete with a subselect:

delete from <table name> where <primary key> in (
select <primary key> from <table name> order by <some sort key>
limit 50000);

For example:

delete from persons where id in (
select id from persons order by created_at limit 50000);

Alexander.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Kristo Kaiv 2007-11-15 12:15:01 implicit casting bug or feature?
Previous Message Abraham, Danny 2007-11-15 10:25:17 Chunk Delete