## Not run:
#
# cl = makeCluster(2) # create a SNOW cluster
#
# #function to run a query for each batch of indexes
# job = function(indexBatch)
# dbGetQuery(dbConnection, paste("SELECT weight FROM table WHERE id IN (",paste(indexBatch,collapse=","),")"))
#
# # function to combine all the results, in this case by summing them up
# reduce = function(results) sum(unlist(results))
#
# indices = 1:10000
#
# #run queries in parallel and then sum the results
# totalWeight = parBatchByIndex(indices,job,reduce,cl, 1000)
#
# ## End(Not run)
Run the code above in your browser using DataLab