2014年12月9日星期二

Derick Rethans: Parallelizing document retrieval


In his latest post Derick Rethans shows how to parallelize document retrieval from a MongoDB database via PHP. This makes it possible to speed up the read operation caused by reading each item one at a time.



MongoDB 2.6 has a new feature that allows you to read all the documents from one collection with multiple cursors in parallel. This is done through a database command called parallelCollectionScan. The idea behind it is that it is faster then reading all the documents in a collection sequentially.


He includes an example snippet that enables the "parallelCollectionScan" handling for a "cities" collection and the resulting output. He shows how to manually create MongoCommandCursors (or let the driver do it for you) and use PHP's own MultipleIterator to process all of the cursors at essentially the same time.


Link: http://derickrethans.nl/parallelcollectionscan.html

没有评论:

发表评论