Skip to Content

TheBlogReaders.com

Salesforce.com, PHP, MySQL, Javascript, Ajax, Htacces

MongoDB Interview Questions and Answers For Freshers Part-5

Be First!

mongodb41.Can you configure the cache size for MMAPv1? How?
No. MMAPv1 does not allow configuring the cache size.

42.Can you configure the cache size for WiredTiger? How?
For the WiredTiger storage engine, you can specify the maximum size of the cache that WiredTiger will use for all data. This can be done using storage.wiredTiger.engineConfig.cacheSizeGB option.

43.How does MongoDB provide concurrency?
MongoDB uses reader-writer locks that allow concurrent readers shared access to a resource, such as a database or collection, but give exclusive access to a single write operation.

44.How can you isolate your cursors from intervening with the write operations?
You can use the snapshot() method on a cursor to isolate the operation for a very specific case. snapshot() traverses the index on the _id field and guarantees that the query will return each document no more than once.

45.Can one MongoDB operation lock more than one databases? If yes, how?
Yes. Operations like copyDatabase(), repairDatabase(), etc. can lock more than onne databases involved.

46.How can concurrency affect replica sets primary?
In replication, when MongoDB writes to a collection on the primary, MongoDB also writes to the primary’s oplog, which is a special collection in the local database. Therefore, MongoDB must lock both the collection’s database and the local database.

47.What is GridFS?
GridFS is a specification for storing and retrieving files that exceed the BSON-document size limit of 16MB. Instead of storing a file in a single document, GridFS divides a file into parts, or chunks, and stores each of those chunks as a separate document.

48.Can you run multiple Javascript operations in a single mongod instance?
Yes. The V8 JavaScript engine added in 2.4 allows multiple JavaScript operations to run at the same time.

49.Which command can be used to provide various information on the query plans used by a MongoDB query?
The explain() command can be used for this information. The possible modes are: ‘queryPlanner’, ‘executionStats’, and ‘allPlansExecution’.

50.How can you achieve primary key – foreign key relationships in MongoDB?
By default MongoDB does not support such primary key – foreign key relationships. However, we can achieve this concept by embedding one document inside another. Foe e.g. an address document can be embedded inside customer document.

(166)

Previous
Next

Leave a Reply