Re: can we add SKIP LOCKED to UPDATE? - Mailing list pgsql-hackers

From Jeff Janes
Subject Re: can we add SKIP LOCKED to UPDATE?
Date
Msg-id CAMkU=1xXqhDn_kpU1TEHt03oEK=-VdX7u5F7j2E-ekySdvz25Q@mail.gmail.com
Whole thread Raw
In response to Re: can we add SKIP LOCKED to UPDATE?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: can we add SKIP LOCKED to UPDATE?  (Craig Ringer <craig@2ndquadrant.com>)
Re: can we add SKIP LOCKED to UPDATE?  (德哥 <digoal@126.com>)
List pgsql-hackers
On Mon, Nov 9, 2015 at 9:06 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> 德哥 <digoal@126.com> writes:
>>    PostgreSQL 9.5 added skip locked to select for update to improve concurrency performance, but why not add it to
updatesql?
 
>
> Seems like you'd have unpredictable results from the update then.

But with use of RETURNING, you could at least know what those results
were and so could deal with the unpredictability.

I don't understand Digoal's use case (Google Translate does a poor job
on the linked page), but this would be handy in conjunction with LIMIT
(which also doesn't exist for UPDATE right now).

update work_queue set assigned='Jeff' where assigned is null and
skills_needed <@ '{whining,"breaking things"}'  limit 1 skip locked
returning id, description

In 9.5 you will be able to do it with a subselect, but putting them
directly on the UPDATE would be easier to understand, and perhaps more
efficient to execute.

Cheers,

Jeff



pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: proposal: PL/Pythonu - function ereport
Next
From: Marco Nenciarini
Date:
Subject: pg_receivexlog: spurious error message connecting to 9.3