Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion priority queue with mongodb

Received: by 10.229.212.137 with SMTP id gs9mr16577qcb.15.1280763020205;
        Mon, 02 Aug 2010 08:30:20 -0700 (PDT)
X-BeenThere: mongodb-user@googlegroups.com
Received: by 10.229.207.84 with SMTP id fx20ls74612qcb.0.p; Mon, 02 Aug 2010 
	08:30:16 -0700 (PDT)
Received: by 10.229.247.203 with SMTP id md11mr16392qcb.4.1280763016564;
        Mon, 02 Aug 2010 08:30:16 -0700 (PDT)
Received: by 10.229.247.203 with SMTP id md11mr16391qcb.4.1280763016538;
        Mon, 02 Aug 2010 08:30:16 -0700 (PDT)
Return-Path: <m...@10gen.com>
Received: from mail-qw0-f50.google.com (mail-qw0-f50.google.com [209.85.216.50])
        by gmr-mx.google.com with ESMTP id y16si89726qce.0.2010.08.02.08.30.16;
        Mon, 02 Aug 2010 08:30:16 -0700 (PDT)
Received-SPF: neutral (google.com: 209.85.216.50 is neither permitted nor denied by best guess record for domain of m...@10gen.com) client-ip=209.85.216.50;
Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 209.85.216.50 is neither permitted nor denied by best guess record for domain of m...@10gen.com) smtp.mail=m...@10gen.com
Received: by mail-qw0-f50.google.com with SMTP id 26so2049336qwa.37
        for <mongodb-user@googlegroups.com>; Mon, 02 Aug 2010 08:30:16 -0700 (PDT)
Received: by 10.229.204.169 with SMTP id fm41mr190782qcb.259.1280763016051;
        Mon, 02 Aug 2010 08:30:16 -0700 (PDT)
Return-Path: <m...@10gen.com>
Received: from mail-qw0-f45.google.com (mail-qw0-f45.google.com [209.85.216.45])
        by mx.google.com with ESMTPS id r38sm187276qcs.38.2010.08.02.08.30.14
        (version=SSLv3 cipher=RC4-MD5);
        Mon, 02 Aug 2010 08:30:15 -0700 (PDT)
Received: by qwi4 with SMTP id 4so1732939qwi.4
        for <mongodb-user@googlegroups.com>; Mon, 02 Aug 2010 08:30:14 -0700 (PDT)
Received: by 10.229.1.95 with SMTP id 31mr195288qce.239.1280763014263; Mon, 02 
	Aug 2010 08:30:14 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.229.72.170 with HTTP; Mon, 2 Aug 2010 08:29:45 -0700 (PDT)
In-Reply-To: <711d031a-468d-40af-a871-a35d1dd2631e@v6g2000prd.googlegroups.com>
References: <711d031a-468d-40af-a871-a35d1dd26...@v6g2000prd.googlegroups.com>
From: Michael Dirolf <m...@10gen.com>
Date: Mon, 2 Aug 2010 11:29:45 -0400
Message-ID: <AANLkTin2EER5d+d8amTBxUX12yu9L+nOEhHP8v_=c...@mail.gmail.com>
Subject: Re: [mongodb-user] priority queue with mongodb
To: mongodb-user@googlegroups.com
Content-Type: text/plain; charset=UTF-8

I think the best bet will probably be to use findAndModify. The
update/limit that you suggest would be subject to race conditions,
etc. Some sort of bulk findAndModify would be interesting but for now
I would just do multiple calls.

On Mon, Aug 2, 2010 at 10:07 AM, bizz <hers...@gmail.com> wrote:
> Hi,
>
> I want to use mongodb to create jobs priority queue.
> I created a collection containing all the jobs, each job has priority
> and minimum time for the next execution.
> Now, I want to query for bulk of jobs to execute. (I use the java
> client to do so)
> I use the find method to query, sort and limit the jobs I want, and in
> return I get a cursor.
>
> My problem:
> After I get the results I would like to mark the jobs as being
> processed. I could come up with the next options:
> 1. go over all the results (one by one with the cursor) and collect
> all the ids, then use the update method to mark the jobs.
> 2. move all the jobs to a new collection dedicated to the processing
> client
> 3. Not use the find method, and instead use FindAndModify for the
> number of jobs I want, one by one
>
> The options listed above have bad performance, because I have to go
> over the jobs one by one to collect their ids so I could mark them as
> being executed.
>
> If I had one of the following features I would have been able to
> perform this task:
> 1. FindAndModify on bulk of entries
> 2. Update with limit (so I could update using the original query)
> 3. An option to get all the results from the find and not a cursor
>
> I couldn't think of any other way that I could do this task with
> better performance,
> Anyone have an Idea?
>
> Thanks
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongodb-user@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>
>