Skip site navigation (1) Skip section navigation (2)

Re: DELETE with LIMIT (or my first hack)

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Csaba Nagy <ncslists(at)googlemail(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Jaime Casanova <jaime(at)2ndquadrant(dot)com>, Daniel Loureiro <loureirorg(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: DELETE with LIMIT (or my first hack)
Date: 2010-11-30 14:19:26
Message-ID: AANLkTimc6qdcD9c+MJS+85dpbY6ovvbmQVrZRtkbq5ey@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
On Tue, Nov 30, 2010 at 4:25 AM, Csaba Nagy <ncslists(at)googlemail(dot)com> wrote:
> The workaround recommended some time ago by Tom is:
>
> DELETE FROM residents_of_athens WHERE ctid = any(array(SELECT ctid FROM
> residents_of_athens ORDER BY ostracism_votes DESC LIMIT 1));
>
> It is about as efficient as the requested feature would be, just uglier
> to write down. I use it all the time when batch-deleting something large
> (to avoid long running transactions and to not crash slony). It also
> helps to vacuum frequently if you do that on large amount of data...

That's a very elegant hack, but not exactly obvious to a novice user
or, say, me.  So I think it'd be nicer to have the obvious syntax
work.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

pgsql-hackers by date

Next:From: Robert HaasDate: 2010-11-30 14:23:33
Subject: Re: GiST insert algorithm rewrite
Previous:From: David FetterDate: 2010-11-30 14:15:08
Subject: Re: Tab completion for view triggers in psql

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group