Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are multiple queries submitted to MongoDB carried out in parallel or serial?

Theoretical scenarios:

I submit a query and then in 5 minutes I would like to submit a second query in parallel.

I submit 5 queries at the same time and they are not related whatsoever.

Will MongoDB carry these out in parallel? I have a many-core server and would like to know if it is possible to do such parallelization

like image 608
oiiio Avatar asked Jan 26 '12 23:01

oiiio


People also ask

How does MongoDB detect multiple data?

MongoDB provides the find() that is used to find multiple values or documents from the collection. The find() method returns a cursor of the result set and prints all the documents. To find the multiple values, we can use the aggregation operations that are provided by MongoDB itself.

How does MongoDB handle concurrent request?

MongoDB allows multiple clients to read and write the same data. To ensure consistency, MongoDB uses locking and concurrency control to prevent clients from modifying the same data simultaneously. Writes to a single document occur either in full or not at all, and clients always see consistent data.

What is parallel query processing?

Parallel query processing designates the transformation of high-level queries into execution plans that can be efficiently executed in parallel, on a multiprocessor computer. This is achieved by exploiting the way data is placed in parallel and the various execution techniques offered by the parallel database system.


1 Answers

Yes, it definitely runs simultaneous commands in parallel.

From the official documentation http://www.mongodb.org/display/DOCS/How+does+concurrency+work :

The mongod process uses a modified reader/writer lock with dynamic yielding on page faults and long operations. Any number of concurrent read operations are allowed, but a write operation can block all other operations.

You can also scale (run in parallel) inserts and updates via sharding, where the write operations are spread across many servers. More here: http://www.mongodb.org/display/DOCS/Sharding+Introduction

like image 173
Eve Freeman Avatar answered Jan 01 '23 21:01

Eve Freeman