Re: UPDATE & LIMIT together?

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: tp(at)emaze(dot)net
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: UPDATE & LIMIT together?
Date: 2002-09-03 18:39:09
Message-ID: 200209031839.g83Id9o07705@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Oleg Bartunov 2002-09-03 18:42:44 Re: tree structures in sql - my point of view (with request
Previous Message Josh Berkus 2002-09-03 18:17:38 Re: tree structures in sql - my point of view (with request of comment from joe celko)