Re: LIMIT for UPDATE and DELETE - Mailing list pgsql-hackers

From Kevin Grittner
Subject Re: LIMIT for UPDATE and DELETE
Date
Msg-id 1408973153.27724.YahooMailNeo@web122301.mail.ne1.yahoo.com
Whole thread Raw
In response to Re: LIMIT for UPDATE and DELETE  (Etsuro Fujita <fujita.etsuro@lab.ntt.co.jp>)
List pgsql-hackers
Etsuro Fujita <fujita.etsuro@lab.ntt.co.jp> wrote:
> (2014/08/15 6:18), Rukh Meski wrote:
>> Based on the feedback on my previous patch, I've separated only the
>> LIMIT part into its own feature.  This version plays nicely with
>> inheritance.  The intended use is splitting up big UPDATEs and DELETEs
>> into batches more easily and efficiently.
>
> Before looking into the patch, I'd like to know the use cases in more
> details.

There have been a few times I wanted something like this, so that
it was easier to do an update that affects a very high percentage
of rows in a table, while making the old version of the row no
longer match the selection criteria for the UPDATE.  There are
workarounds using cursors or subselects returning ctid, but they
are kludgy and error prone.  Basically I wanted to alternate UPDATE
of a subset of the rows with table VACUUM so that subsequent
iterations can re-use space and avoid bloating the table.

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: Allow multi-byte characters as escape in SIMILAR TO and SUBSTRING
Next
From: Kevin Grittner
Date:
Subject: Re: Hardening pg_upgrade