iwantcoding.com
🔥 Daily 👥 Rooms 🏆 Top Log in Sign up

MongoDB Quiz

Eight quick questions on MongoDB indexes, aggregations, transactions, and operational gotchas.

Sample questions

EXAMPLE
# MongoDB quiz

1) Which is true about indexes?
   a) every field is automatically indexed
   b) you must create them; reads without an index do a COLLSCAN
   c) only _id can be indexed
   d) indexes are write-only

2) Compound index { a: 1, b: 1 }:
   a) helps queries on b alone
   b) helps queries on a alone and queries on a + b
   c) is only for sorting
   d) is the same as { b: 1, a: 1 }

3) explain('executionStats') is for:
   a) collection size
   b) reading query plan + actual execution time
   c) replication lag
   d) journal config

4) Transactions across collections:
   a) impossible
   b) require a replica set or sharded cluster
   c) require a single-node setup
   d) require Atlas

5) Aggregation \$match should come:
   a) at the end
   b) as early as possible so following stages process fewer docs
   c) only in \$group
   d) never

6) TTL indexes do:
   a) full-text search
   b) automatically delete docs after expireAfterSeconds
   c) replicate to a secondary
   d) sort by date

7) Atlas Performance Advisor recommends:
   a) sharding shape
   b) missing indexes inferred from real query traffic
   c) deployment region
   d) schema version

8) Logical backup tool:
   a) mongo
   b) mongodump
   c) mongorestore
   d) mongos

Answers: 1b, 2b, 3b, 4b, 5b, 6b, 7b, 8b.

Why it matters

Indexes + explain plans + early \\$match cover 80 percent of MongoDB performance work. Transactions and TTL are the most-misunderstood operational features. If you nail those, the rest is schema design.

Tip: Tweak the snippet with Try it Yourself », then sit the quiz at the bottom of the page.

Example

Example
// 3 questions per lesson.
Try it Yourself »

Discussion

Loading…