bizz
unread,Aug 2, 2010, 10:07:33 AM8/2/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mongodb-user
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