pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <pgman@candle.pha.pa.us>
To: tp@emaze.net
Cc: pgsql-sql@postgresql.org
Subject: Re: UPDATE & LIMIT together?
Date: Tue, 3 Sep 2002 14:39:09 -0400 (EDT)
Message-ID: <200209031839.g83Id9o07705@candle.pha.pa.us> (raw)
In-Reply-To: <20020903083727.GH5674@emaze.net>

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, Pennsylvania 19073



view thread (4+ messages)

Message-ID: <200209031839.g83Id9o07705@candle.pha.pa.us>
Permalink:  ../200209031839.g83Id9o07705@candle.pha.pa.us/
Also on:    postgresql.org/message-id/200209031839.g83Id9o07705@candle.pha.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: pgman@candle.pha.pa.us, tp@emaze.net
  Subject: Re: UPDATE & LIMIT together?
  In-Reply-To: <200209031839.g83Id9o07705@candle.pha.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox