Is mongodb handle query one by one?

mongodb concurrency
mongodb parallel query
mongodb query and projection
mongodb atlas
pymongo
mongodb projection
mongodb find multiple values
mongodb lock collection

Assume I have a mongodb instance on a remote server (1 core cpu and 8G memory). When I send a simple query db.table.find({_id:ObjectId('xxx')}).limit(1).explain()to the instance, I got the result show that query cost 10ms. So can I come to a conclusion that "my mongodb server can only handle 100 simple query per second"?

"So can I come to a conclusion that "my mongodb server can only handle 100 simple query per second""

Its not tht like that 1 query takes 10ms then 100 query will take 1sec db.table.find({_id:ObjectId('xxx')}).limit(1) will not lock your table So if your 100 client request this with 100 connections all will return in 10ms Concurrency Depends upon locks and connection limits

If a query locking collection for read and write for 10 sec then all query after that will wait for lock to cleared

MongoDb Can Handle multiple Request

db.runCommand( { serverStatus: 1 } ) will return current status of mongo there is object in

"connections" : {
    "current" : <num>,
    "available" : <num>,
    "totalCreated" : <num>,
    "active" : <num>
}

https://docs.mongodb.com/manual/reference/command/serverStatus/#connections

https://docs.mongodb.com/manual/reference/configuration-options/#net.maxIncomingConnections

https://docs.mongodb.com/manual/faq/concurrency/

These will give more clarity around connections and its limits

db.collection.findOne() — MongoDB Manual, Returns one document that satisfies the specified query criteria on the collection or view. If multiple documents satisfy the query, this method returns the first� For corresponding MongoDB driver API, refer to your specific MongoDB driver documentation instead. Returns one document that satisfies the specified query criteria on the collection or view . If multiple documents satisfy the query, this method returns the first document according to the natural order which reflects the order of documents on

You should know, your mongodb server can handle many parallel queries.

FAQ: Concurrency — MongoDB Manual, Does a MongoDB operation ever lock more than one database? MongoDB uses multi-granularity locking [1] that allows operations to lock at the global,� The intent of the article is to provide a list of all the possible commands that can be used on a given MongoDB database instance version (v.3.4.7). As mentioned earlier, the entirety of these commands may not work as is on any other version of MongoDB database instance as there are features dropped and added with each possible version of MongoDB.

your assumption is incorrect, cuz u are ignoring the fact that mongodb supports concurrency

Source

FAQ: MongoDB Fundamentals — MongoDB Manual, Does MongoDB handle caching? How does Each document has one or more fields; fields are similar to the columns in a relational database table. See also. MongoDB offers high speed, high availability, and high scalability. Fetching data from MongoDB. Pymongo provides varoius methods for fetching the data from mongodb. Let’s see them one by one. 1) Find One: This method is used to fetch data from collection in mongoDB. It returns first first occurrence. Syntax: find_one() Example:

Query an Array — MongoDB Manual, To query if the array field contains at least one element with the specified value, use the filter { <field>: <value> } where <value> is the element value. This page provides examples of query operations on embedded/nested documents using the com.mongodb.reactivestreams.client.MongoCollection.find method in the MongoDB Java Reactive Streams Driver. The examples on this page use the inventory collection. To populate the inventory collection, run the following:

Query Documents — MongoDB Manual, How do I query documents, query top level fields, perform equality match, query with A compound query can specify conditions for more than one field in the� With the embedded data model, your application can retrieve the complete patron information with one query. Subset Pattern ¶ A potential problem with the embedded document pattern is that it can lead to large documents, especially if the embedded field is unbounded.

SQL to MongoDB Mapping Chart — MongoDB Manual, Some of the SQL queries below may include an _id field to reflect this, even if the field is not included in the corresponding find() query. SQL SELECT Statements� mongo Shell Method. This page documents the mongo shell method, and does not refer to the MongoDB Node.js driver (or any other driver) method. For corresponding MongoDB driver API, refer to your specific MongoDB driver documentation instead.

Comments
  • How did you time that, from the web server? Then it would include the time taken to pass and process the data to the web service as well as any network latency depending where they are in relation to each other.