On Tue, Jun 10, 2008 at 4:40 AM, Nikola Milutinovic <alokin1@xxxxxxxxx> wrote: > Hi all. > > This may be trivial, but I cannot find good references for it. The problem > is this: > > Suppose we have one table in PgSQL which is a job queue, each row represents > one job with several status flags, IDs,... Several processes will attempt to > access the queue and "take" their batch of jobs, the batch will have some > parameterizable size. So, the simple idea is "select N lowest IDs that do > not have a flag <in process> set and set the flag", "then proceed with > whatever it is that should be done". Do the jobs HAVE to be assigned sequentially in groups? I.e. is it only allowable to assign jobs 1-10 to one thread, then 11 through 18 to the next? Or could you assign 1,2,3,6,7,8,9,10 to one, and 4,5,11,12... to another? If so, assign them with a separate sequence.