Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Derick Rethans:
Parallelizing document retrieval
Dec 09, 2014 @ 17:59:20

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.

tagged: mongodb driver parallel document retrieval cursor iterator

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


Trending Topics: