On Nov 4, 2009, at 8:47 AM, Jeff Janes wrote:
I do a select for update in a stored proc: FOR queue_item IN SELECT * FROM queue LOOP UPDATE queue_proc set status = 'proc' where id = queue_item.id ; The daemons keep track of their last position in the queue with low_bound_id. Also, as you probably notice, I also fetch a batch of (100) items at a time. In practice, it's pretty fast. The job I'm running now is showing an average fetch time of 30ms per 100 actions, which ain't bad.
First commit occurs after the stored proc to select/update a batch of items is complete. Second commit occurs on the writing of results back for each particular action. Two commits are required because the time it takes to complete the intervening action can vary wildly: anywhere between 20ms and 45min.
The final update is a different query -- just a plain old update by ID: UPDATE queue_proc set status = 'proc' where id = %s ; This update by ID takes ~2.5ms, which means it's where the framework is spending most of its overhead. Brian |