Re: UPDATE & LIMIT together? - Mailing list pgsql-sql

From Bruce Momjian
Subject Re: UPDATE & LIMIT together?
Date
Msg-id 200209031839.g83Id9o07705@candle.pha.pa.us
Whole thread Raw
In response to Re: UPDATE & LIMIT together?  (tp <tp@emaze.net>)
List pgsql-sql
tp wrote:
> Hmm,,
> 
> thanks so far, it helped.
> 
> The query is horrible slow on full tables (>100.000 rows).
> Is there any other solution? I just want to have the 'next 10 entries'
> WHERE state=10 and update state=20.
> (so that on the next request i or another process only gets the 
> new entires in queue).
> 
> 
> My query now looks like:
> UPDATE queue SET state=20 WHERE (id) IN (SELECT id FROM queue LIMIT 10)

Without an ORDER BY, I am not sure what that LIMIT is returning.

I don't know of a faster way.

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
359-1001+  If your life is a hard drive,     |  13 Roberts Road +  Christ can be your backup.        |  Newtown Square,
Pennsylvania19073
 


pgsql-sql by date:

Previous
From: Josh Berkus
Date:
Subject: Re: tree structures in sql - my point of view (with request of comment from joe celko)
Next
From: Peter Eisentraut
Date:
Subject: Re: Update Help