Search Postgresql Archives

Re: Chunk Delete

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/15/07, Abraham, Danny <danny_abraham@xxxxxxx> 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.

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux