MongoDB MCQs – Scaling and Monitoring

11.) What does the profiler in MongoDB do?

A) Monitors slow queries
B) Compresses data
C) Creates indexes automatically
D) Removes duplicate documents

Answer: Option A

Explanation: The MongoDB profiler captures slow queries to help in performance analysis.

12.) Which MongoDB operation locks the database during execution?

A) find()
B) updateMany()
C) createIndex()
D) countDocuments()

Answer: Option C

Explanation: Index creation can temporarily lock the database, affecting write operations.

13.) How does journaling help in MongoDB?

A) Improves write performance
B) Provides crash recovery
C) Increases indexing speed
D) Reduces disk usage

Answer: Option B

Explanation: Journaling ensures data durability by recording operations before committing them to the database.

14.) Which tool allows you to analyze MongoDB performance over time?

A) mongos
B) mongotop
C) Ops Manager
D) mongoexport

Answer: Option C

Explanation: Ops Manager provides historical performance metrics and monitoring for MongoDB deployments.

15.) What is the default port for MongoDB?

A) 3306
B) 5432
C) 27017
D) 8080

Answer: Option C

Explanation: MongoDB listens on port 27017 by default.

16.) What is the main advantage of a TTL index in MongoDB?

A) Reduces query time
B) Automatically deletes old documents
C) Prevents duplicate records
D) Improves write performance

Answer: Option B

Explanation: TTL (Time-To-Live) indexes automatically delete expired documents.

17.) Which read concern level ensures only committed data is read?

A) local
B) snapshot
C) available
D) majority

Answer: Option D

Explanation: The “majority” read concern ensures that data read is confirmed by most replica set members.

18.) What is the role of balancer in MongoDB sharding?

A) Distributes queries among shards
B) Compresses large documents
C) Deletes unused indexes
D) Moves data between shards

Answer: Option D

Explanation: The balancer redistributes data across shards to maintain an even data distribution, preventing uneven load across servers.

19.) Which MongoDB command provides statistics about memory usage and index efficiency?

A) db.stats()
B) db.collection.stats()
C) db.serverStatus()
D) db.indexStats()

Answer: Option B

Explanation: The db.collection.stats() command provides detailed information about a collection, including storage size, index usage, and memory consumption.

20.) How can you distribute query load across multiple replica set members?

A) Use a load balancer
B) Increase the number of indexes
C) Set read preference to secondary
D) Use a primary-only read preference

Answer: Option C

Explanation: By setting read preference to “secondary”, you allow read queries to be distributed across secondary nodes, reducing the load on the primary node.

Leave a Reply

Your email address will not be published. Required fields are marked *