Question 1: What is the main purpose of MongoDB indexes?
- Reduce storage size
- Improve query performance
- Enforce schema rules
- Handle replication
Explanation: Indexes speed up query execution by reducing scanned documents.
This intermediate-level MongoDB quiz is designed for developers who understand the basics and want to test applied, real-world MongoDB concepts. It focuses on querying, indexing, aggregation, schema design, performance, and common interview scenarios.
Explanation: Indexes speed up query execution by reducing scanned documents.
Explanation: Single-field indexes efficiently support range queries.
Explanation: Compound indexes include multiple fields in a defined order.
Explanation: explain() shows how MongoDB executes a query.
Explanation: Aggregation processes and transforms data through stages.
Explanation: $match filters documents in the pipeline.
Explanation: $project controls fields and structure.
Explanation: $group groups documents by a key.
Explanation: $sum adds numeric values.
Explanation: $avg computes the average.
Explanation: MongoDB automatically creates an index on _id.
Explanation: Text indexes support text search queries.
Explanation: $lookup performs left outer joins.
Explanation: Schema validation enforces document structure.
Explanation: Schema rules are defined during createCollection.
Explanation: j:true ensures journal commit.
Explanation: Read preference controls read source.
Explanation: Primary ensures up-to-date reads.
Explanation: Replica sets provide redundancy and availability.
Explanation: Writes go to the primary node.
Explanation: Arbiters help in primary elections.
Explanation: Sharding distributes data across servers.
Explanation: Shard key determines data distribution.
Explanation: Even distribution avoids hotspots.
Explanation: $limit restricts result count.
Explanation: $skip skips a number of documents.
Explanation: $sort orders documents.
Explanation: $unwind deconstructs arrays.
Explanation: 2dsphere supports location-based queries.
Explanation: replaceOne replaces the whole document.
Explanation: $unset removes a field.
Explanation: $pull removes matching array elements.
Explanation: $addToSet avoids duplicates.
Explanation: Unique indexes enforce uniqueness.
Explanation: TTL indexes remove expired documents.
Explanation: stats() shows collection metrics.
Explanation: Keys examined shows index usage.
Explanation: Covered queries read only indexes.
Explanation: MongoDB provides snapshot isolation.
Explanation: Single document updates are atomic.
Explanation: MongoDB 4.0 introduced transactions.
Explanation: Durability ensures data persistence.
Explanation: Oplog backups support point-in-time recovery.
Explanation: mongodump is used for backups.
Explanation: mongostat shows real-time stats.
Explanation: Embedding works well for one-to-many.
Explanation: Documents are limited to 16MB.
Explanation: Fewer indexes improve write performance.
Explanation: MongoDB is designed for horizontal scaling.
This intermediate-level MongoDB quiz is designed for developers who understand the basics and want to test applied, real-world MongoDB concepts. It focuses on querying, indexing, aggregation, schema design, performance, and common interview scenarios.