pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Csaba Nagy <nagy@ecircle-ag.com>
To: Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>
Cc: Postgres general mailing list <pgsql-general@postgresql.org>
Subject: Re: [JDBC] Is what I want possible and if so how?
Date: Mon, 03 Jul 2006 17:16:33 +0200
Message-ID: <1151939793.13456.40.camel@coppola.muc.ecircle.de> (raw)
In-Reply-To: <3097.1151939008@sss.pgh.pa.us>
References: <1151923545.6055.40.camel@localhost>
	<3097.1151939008@sss.pgh.pa.us>

On Mon, 2006-07-03 at 17:03, Tom Lane wrote:
> status and TX2's select will not return the row.  This isn't entirely
> perfect because LIMIT acts before FOR UPDATE: TX2's select will return
> nothing, rather than selecting the next available row as you might wish.
> So you might want to retry the select several times before deciding
> there's nothing to do.

We do have a table like this, and in fact we did observe this behavior
that if multiple clients ask for a row at the same time, the first gets
something and the rest nothing. We're actually still looking for an
optimal solution for this...

For now, we added a random field to the table (with values 0-9), and the
clients asks with a where clause for a random value in this field. This
way there's a good chance the clients will not tip on each other's toes
(i.e. the row asked for is not locked by another client). It is still
necessary to retry a few times, but after introducing this random number
mechanism we did notice a significant performance improvement in
emptying the queue... so it must work somehow. It's true that we usually
have 10-15 clients constantly polling the queue, and the queue itself is
usually loaded with at least a few hundred tasks, so the random numbers
are reasonably distributed to be effective.

Now I wonder if there's some other way to get the same result without
additional column in the table ?

Cheers,
Csaba.





view thread (6+ messages)  latest in thread

Message-ID: <1151939793.13456.40.camel@coppola.muc.ecircle.de>
Permalink:  ../1151939793.13456.40.camel@coppola.muc.ecircle.de/
Also on:    postgresql.org/message-id/1151939793.13456.40.camel@coppola.muc.ecircle.de

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: nagy@ecircle-ag.com, J.Kraaijeveld@Askesis.nl, pgsql-general@postgresql.org
  Subject: Re: [JDBC] Is what I want possible and if so how?
  In-Reply-To: <1151939793.13456.40.camel@coppola.muc.ecircle.de>
  References: <1151923545.6055.40.camel@localhost> <3097.1151939008@sss.pgh.pa.us> <1151939793.13456.40.camel@coppola.muc.ecircle.de>

* 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