MongoDB Certified Associate Database Administrator

Question bank

MongoDB logo

MongoDB Certified Associate Database Administrator

MongoDB-DBA

44 MongoDB Certified Associate Database Administrator questions with the correct answer and a written explanation, organised across 7 exam domains.

44 questions
7 domains
Foundation level

Question index

Jump straight to any question. Answers and explanations are inline.

CRUD Operations

11 questions in this domain

  1. Question 1Single Choice

    Which statement best describes a single-field index in MongoDB?

    • AAn index created on a single field of a document.Correct answer
    • BAn index that combines two or more fields.
    • CAn index that stores the entire document.
    • DAn index that requires a unique constraint.

    Why this is the answer

    A single-field index is built on one field and speeds up equality and range queries on that key. It is the fundamental building block for query performance.

  2. Question 2Multiple Select

    What statements accurately describe compound indexes?

    • AThey reference multiple fields in a single B-tree structure.Correct answer
    • BThe order of fields in the index is important.Correct answer
    • CField order has no effect on query support.
    • DThey cannot support queries on leading fields.

    Why this is the answer

    Compound indexes hold references to several fields in one B-tree. Field order is critical and queries can use the leading prefix of the index.

  3. Question 3Interactive

    The code block creates a compound index. Based on the Prefix Rule, which query can be efficiently supported?

    • Adb.orders.find({ a: 5 })Correct answer
    • Bdb.orders.find({ b: 5 })
    • Cdb.orders.find({}).sort({ b: 1 })
    • Ddb.orders.find({ c: 5 })

    Why this is the answer

    The Prefix Rule lets an index support queries that include its leftmost fields. Since the index is on {a:1,b:1}, querying only on a uses the prefix; b alone cannot.

  4. Question 4Single Choice

    What does the Prefix Rule state about compound indexes?

    • AOnly the rightmost field of an index can be used.
    • BA compound index supports queries on its leading leftmost fields.Correct answer
    • CAny field in a compound index can be used independently.
    • DThe prefix rule only applies to TTL indexes.

    Why this is the answer

    The Prefix Rule states that a compound index supports queries on the leading fields, but cannot efficiently support queries on later fields alone.

  5. Question 5Multiple Select

    Which problems can result from over-indexing a MongoDB collection?

    • AHigh write latency.Correct answer
    • BMemory pressure in the WiredTiger cache.Correct answer
    • CFaster deletes with no overhead.
    • DReduced storage usage.

    Why this is the answer

    Each index adds write overhead and consumes cache memory. Over-indexing increases write latency and can exhaust the WiredTiger cache.

  6. Question 6Interactive

    Examine the TTL index in the code block. Which statements about its expiration behavior are true?

    • ADocuments expire 3600 seconds after the lastModified date.Correct answer
    • BThe background thread runs at most once every 60 seconds.Correct answer
    • CDeletion happens instantly when the TTL value is reached.
    • DThe index works with integer timestamp fields.

    Why this is the answer

    TTL indexes delete documents after expireAfterSeconds from the date field. A background thread runs about every 60 seconds and the field must be a BSON date type.

  7. Question 7Single Choice

    On what field type can a TTL index be created?

    • ABSON date type or array of BSON dates.Correct answer
    • BInteger timestamp only.
    • CString date only.
    • DAny numeric value.

    Why this is the answer

    TTL indexes can only be created on single fields containing BSON dates or arrays of BSON dates. Integer timestamps will not trigger expiration.

  8. Question 8Multiple Select

    Which field values are valid for a TTL index?

    • AA BSON date.Correct answer
    • BAn array of BSON dates.Correct answer
    • CA Unix epoch integer.
    • DA string formatted as a date.

    Why this is the answer

    The TTL index only expires documents when the field holds a BSON date or an array of BSON dates. Other types are not supported.

  9. Question 9Interactive

    The explain() output in the code block shows a particular stage. What does this indicate?

    • ACollection scan, indicating a missing index.Correct answer
    • BIndex scan, showing efficient use of an index.
    • CThe query is using a TTL index.
    • DThe query is using compound index intersection.

    Why this is the answer

    COLLSCAN means the database scanned the whole collection. This usually indicates a missing index, unlike IXSCAN which indicates index usage.

  10. Question 10Single Choice

    What is index intersection in MongoDB?

    • AUsing multiple single-field indexes to satisfy a query.Correct answer
    • BCombining two fields into one compound index.
    • CCreating an index on an array field.
    • DDeleting expired documents using a background thread.

    Why this is the answer

    Index intersection uses multiple single-field indexes to answer a query. It is generally less efficient than a well-designed compound index.

  11. Question 11Multiple Select

    Which statements are true about multikey indexes?

    • AThey are created when the indexed field contains an array.Correct answer
    • BMongoDB cannot create a compound multikey index with more than one array field.Correct answer
    • CThey can be used to compound two array fields without restrictions.
    • DThey prevent all queries on array elements.

    Why this is the answer

    Multikey indexes arise when an array value is indexed. MongoDB forbids compound multikey indexes where more than one field is an array to avoid Cartesian product issues.

Indexes

8 questions in this domain

  1. Question 12Single Choice

    What is a single-field index in MongoDB?

    • AAn index on multiple fields in a B-tree structure
    • BAn index on a single field used to speed up queries on that keyCorrect answer
    • CAn index that automatically expires documents
    • DAn index created only on array fields

    Why this is the answer

    A single-field index is built on one field and is the fundamental tool for accelerating equality and range queries on that specific key.

  2. Question 13Multiple Select

    Which statements accurately describe compound indexes?

    • AThey store references to multiple fields in one B-tree structureCorrect answer
    • BField order has no effect on which queries the index can support
    • CThey follow a prefix rule, meaning leftmost fields can support queries by themselvesCorrect answer
    • DCompound indexes are sensitive to sort direction, whereas single-field indexes can be traversed in either directionCorrect answer

    Why this is the answer

    Compound indexes store multiple fields in one B-tree, respect the prefix rule, and require sort direction to match their field order.

  3. Question 14Interactive

    Examine the compound index definition and query in the code block. Which statement about index usage is correct?

    • AThe query uses the index because status is the leading field and the sort order matchesCorrect answer
    • BThe index cannot support sorting by age descending because status is ascending
    • CThe query requires a separate index only on age
    • DThe index will be ignored because it includes a sort field

    Why this is the answer

    The index prefix on status matches the query filter, and the age direction matches the sort, so the compound index is used efficiently.

  4. Question 15Single Choice

    Compared with using index intersection, what is a primary advantage of a well-designed compound index?

    • AIt eliminates the need for all write operations
    • BIt is generally more efficient for satisfying queries on multiple fieldsCorrect answer
    • CIt automatically covers every possible query
    • DIt does not consume any storage space

    Why this is the answer

    Index intersection can satisfy some queries, but a single compound index is usually more efficient and is the preferred design.

  5. Question 16Multiple Select

    Which statements about TTL indexes are true?

    • AThey can only be created on a single field containing BSON date valuesCorrect answer
    • BThey support compound indexes if one field is a date
    • CA background thread removes expired documents approximately every 60 secondsCorrect answer
    • DTTL indexes require integer timestamps and delete documents immediately

    Why this is the answer

    TTL indexes require a single BSON date field and are processed by a background thread at most every 60 seconds.

  6. Question 17Interactive

    Consider the TTL index created in the code block. If the indexed field stores integer Unix timestamps, what is the expected behavior?

    • ADocuments expire after the specified number of seconds
    • BThe index is invalid because integer timestamps are not allowed in any index
    • CDocuments will never be expired because the field is not a BSON DateCorrect answer
    • DThe background thread converts integers to dates and deletes them

    Why this is the answer

    TTL expiration only works on BSON Date fields. Storing integer timestamps means the TTL index will not trigger deletion.

  7. Question 18Single Choice

    In the ESR rule for compound indexes, what does each letter stand for?

    • AEquality, Sort, RangeCorrect answer
    • BExact, Sorted, Random
    • CEntity, Schema, Reference
    • DEvaluate, Scan, Return

    Why this is the answer

    ESR stands for Equality, Sort, Range and is a guideline for ordering fields in a compound index.

  8. Question 19Multiple Select

    Which statements about multikey indexes are true?

    • AA compound multikey index can include more than one array field
    • BMultikey indexes are used when the indexed field contains an arrayCorrect answer
    • CMongoDB cannot build a compound multikey index with more than one array fieldCorrect answer
    • DCovered queries are easier with multikey indexes because they expand automatically

    Why this is the answer

    A multikey index is created on array fields, but MongoDB prohibits more than one array field in a compound multikey index to avoid Cartesian explosions.

Monitoring & Performance Tuning

4 questions in this domain

  1. Question 20Single Choice

    What type of index is the fundamental building block used to speed up equality and range queries on a specific key?

    • ASingle-field indexCorrect answer
    • BCompound index
    • CMultikey index
    • DTTL index

    Why this is the answer

    A single-field index is created on one document field and is the fundamental tool for optimizing equality and range queries on a specific key.

  2. Question 21Multiple Select

    Which two statements accurately describe how TTL indexes handle the automatic expiration and eventual deletion of stored documents?

    • ARequires a single field containing a BSON dateCorrect answer
    • BBackground thread runs at most once every 60 secondsCorrect answer
    • CWorks with integer Unix timestamps
    • DDeletion occurs immediately when time expires

    Why this is the answer

    TTL indexes require BSON date fields, are processed by a background thread at most every 60 seconds, and deletions are eventually consistent rather than immediate.

  3. Question 22Interactive

    The code block contains explain() output for a query. Which stage in the winning plan proves that the query used an index?

    • AIXSCANCorrect answer
    • BCOLLSCAN
    • CSORT
    • DFETCH

    Why this is the answer

    IXSCAN is the execution stage that indicates an index was used, while COLLSCAN indicates a collection scan. The other stages are not evidence of index usage.

  4. Question 23Single Choice

    According to the Prefix Rule, which query can a compound index on {a: 1, b: 1} efficiently support?

    • Adb.collection.find({ a: 1 })Correct answer
    • Bdb.collection.find({ b: 1 })
    • Cdb.collection.find({}).sort({ b: 1 })
    • Ddb.collection.find({ c: 1 })

    Why this is the answer

    The Prefix Rule allows a compound index to support queries on its leading fields; {a:1,b:1} supports {a:1} but not {b:1} alone.

Philosophy & Features

4 questions in this domain

  1. Question 24Single Choice

    What does the Prefix Rule state about compound indexes in MongoDB?

    • AAn index can support queries that include the leading fields of the index.Correct answer
    • BAn index can support queries on any field, regardless of position.
    • CAn index can only support equality filters, never range filters.
    • DAn index is valid only if all fields are used in the query.

    Why this is the answer

    The prefix rule means a compound index can serve queries that filter on its leftmost fields. A query on the leading fields can use the index, while a query on a later field alone cannot.

  2. Question 25Multiple Select

    Which two statements about TTL indexes are correct in MongoDB?

    • ATTL indexes require a single field that contains a BSON date or an array of BSON dates.Correct answer
    • BTTL indexes can be created on compound indexes.
    • CTTL indexes accept integer Unix timestamps for expiration.
    • DTTL expiration is processed by a background thread that runs at most once every 60 seconds.Correct answer

    Why this is the answer

    TTL indexes are single-field indexes on BSON date values. A background thread deletes expired documents at most every 60 seconds. Compound indexes and integer timestamps are not supported.

  3. Question 26Interactive

    Look at the index creation and query in the code block. According to the prefix rule, which statement is correct?

    • AThe index cannot efficiently support the query because it filters only on the non-prefix field b.Correct answer
    • BThe index will be used because every index field is available in the query.
    • CMongoDB will ignore the index and always sort in memory.
    • DThe query will fail because field b is not indexed.

    Why this is the answer

    Because the leading field is a and the query filters only on b, the compound index cannot be used efficiently. The prefix rule requires the leftmost fields to be included in the query.

  4. Question 27Single Choice

    Which statement about single-field indexes and sort order is true?

    • AA single-field index can be traversed in either direction for sorts.Correct answer
    • BA single-field index cannot be used for sorting at all.
    • CA single-field index only works for ascending sorts.
    • DA single-field index must have a matching compound index.

    Why this is the answer

    Unlike compound indexes, a single-field index is direction-agnostic. MongoDB can traverse it forward or backward, so it can satisfy ascending or descending sorts.

Replication

6 questions in this domain

  1. Question 28Single Choice

    What does a single-field index do in MongoDB?

    • ASpeeds up equality and range queries on a keyCorrect answer
    • BCreates a unique constraint on a date field
    • CBuilds compound indexes without field order
    • DAutomatically deletes documents after sixty seconds

    Why this is the answer

    A single-field index is the fundamental building block for performance, speeding up equality and range queries on the indexed key.

  2. Question 29Multiple Select

    Which two statements about compound indexes are true? Select all that apply.

    • AField order in a compound index is paramountCorrect answer
    • BCompound indexes follow increasing selectivityCorrect answer
    • CA compound index can be used starting from any field, regardless of order
    • DSort direction is irrelevant in compound indexes

    Why this is the answer

    Field order determines utility, and compound indexes are built with increasing selectivity. The prefix rule prevents use from rightmost fields alone, and direction matters in compound sorts.

  3. Question 30Interactive

    The code block shows a compound index. According to the Prefix Rule, which query can be efficiently supported by this index?

    • AQuery filtering only on field aCorrect answer
    • BQuery filtering only on field b
    • CQuery filtering only on field c
    • DQuery filtering on neither a nor b

    Why this is the answer

    The Prefix Rule says a compound index can support queries that include the leading leftmost fields. Filtering only on field b ignores the leading field a, so it cannot use the index.

  4. Question 31Single Choice

    Which field type is required by a TTL index to expire documents?

    • ABSON date or array of BSON datesCorrect answer
    • BInteger Unix timestamp
    • CString containing a readable date
    • DAny numeric field

    Why this is the answer

    TTL indexes require a single field containing a BSON date type or an array of BSON dates; integer timestamps do not trigger expiration.

  5. Question 32Multiple Select

    Which of the following are common TTL index traps? Select all that apply.

    • ATTL indexes work on integer timestampsCorrect answer
    • BDeletion happens immediately after expiryCorrect answer
    • CA compound index is required for TTL
    • DTTL deletions have no replication impact

    Why this is the answer

    TTL indexes require a BSON date field, are checked at most every 60 seconds, and their deletions are write operations recorded in the oplog.

  6. Question 33Interactive

    The explain output in the code block shows the winning plan. What does this stage indicate?

    • AIt is using an index scan
    • BIt is performing a collection scanCorrect answer
    • CIt is using a covered query
    • DIt has returned no documents

    Why this is the answer

    COLLSCAN means the database is scanning the entire collection; an IXSCAN stage would indicate index usage.

Security

7 questions in this domain

  1. Question 34Single Choice

    What data type must a TTL index field contain to trigger automatic expiration?

    • ABSON DateCorrect answer
    • BInteger timestamp
    • CString
    • DObjectId

    Why this is the answer

    TTL indexes require a single field containing a BSON date type or an array of BSON date types; integer timestamps do not trigger expiration.

  2. Question 35Multiple Select

    Which statements about TTL index behavior are correct? Select all that apply.

    • ATTL indexes can only be created on a single field.Correct answer
    • BThe background expiration thread runs at most once every 60 seconds.Correct answer
    • CDocuments are removed immediately once expireAfterSeconds has passed.
    • DTTL indexes can be created on integer timestamp fields.

    Why this is the answer

    TTL indexes support only single fields; a background thread runs up to every 60 seconds, so deletion is not immediate; integer timestamps are not valid.

  3. Question 36Interactive

    Examine the explain() output in the code block. Which execution stage is shown?

    • ACollection ScanCorrect answer
    • BIndex Scan
    • CSort Merge Join
    • DCovered Query

    Why this is the answer

    COLLSCAN indicates a collection scan, usually meaning no suitable index was used.

  4. Question 37Single Choice

    According to the Prefix Rule, what queries can a compound index on {a: 1, b: 1} support?

    • AQueries filtering on b only
    • BQueries filtering on a only or a and b togetherCorrect answer
    • CQueries filtering on neither a nor b
    • DAny query containing b if sorted by a

    Why this is the answer

    A compound index supports queries on leading leftmost fields; {a:1,b:1} cannot efficiently serve b-only queries.

  5. Question 38Multiple Select

    Which of the following are common mistakes when working with MongoDB indexes? Select all that apply.

    • AIgnoring the index prefix rule when querying a compound indexCorrect answer
    • BAssuming single-field indexes are direction-agnostic for sort operations
    • CCreating indexes on every field to cover all queriesCorrect answer
    • DUsing a TTL index on a BSON date field

    Why this is the answer

    A common trap is ignoring the prefix rule; over-indexing every field causes write latency and memory pressure. Single-field indexes are direction-agnostic, and TTL on BSON date is valid.

  6. Question 39Interactive

    Review the TTL index definition in the code block. What is the most likely reason it will not expire documents?

    • AThe timestamp field is an integer rather than a BSON DateCorrect answer
    • BThe timestamp field is a string
    • CTTL indexes cannot be created on single fields
    • DexpireAfterSeconds must be greater than 86400

    Why this is the answer

    A TTL index requires a BSON date type. The integer timestamp prevents the expiration thread from recognizing the field.

  7. Question 40Single Choice

    What is the primary diagnostic tool for verifying that an index is being used by a query?

    • Aexplain()Correct answer
    • BserverStatus()
    • CindexStats()
    • DcurrentOp()

    Why this is the answer

    explain() reveals the winning plan, including COLLSCAN or IXSCAN, and keys examined.

Server Administration

4 questions in this domain

  1. Question 41Single Choice

    What is the main purpose of a single-field index in MongoDB when a query filters on that field?

    • ASpeeds up simple lookups on that fieldCorrect answer
    • BSpeeds up queries with multiple filter fields
    • CAutomatically created on the _id field
    • DDesigned only for sorting results

    Why this is the answer

    A single-field index speeds up equality and range queries on one key. It is the foundational performance tool but does not directly optimize queries that filter on multiple fields.

  2. Question 42Multiple Select

    Which conditions are required for a TTL index to automatically remove documents after they expire? Select all that apply.

    • ARequires a single BSON date or date-array fieldCorrect answer
    • BWorks with integer Unix timestamps
    • CRuns a background thread every 60 secondsCorrect answer
    • DCan be part of a compound index

    Why this is the answer

    TTL indexes require a single date or date-array field. A background thread runs every 60 seconds to delete expired documents, so integer timestamps and compound TTL indexes are not supported.

  3. Question 43Interactive

    Review the compound index definition in the code block. According to the Prefix Rule, which query can benefit from this index?

    • AFilters only on the leading fieldCorrect answer
    • BFilters only on the second field
    • CFilters only on an unrelated field
    • DRequires no filter fields

    Why this is the answer

    The Prefix Rule states that a compound index supports queries on its leftmost leading fields. A filter on the second field alone cannot use the index efficiently.

  4. Question 44Single Choice

    Which data type must be stored in a field for a TTL index to mark that document for expiration?

    • ABSON date or array of BSON datesCorrect answer
    • BInteger Unix timestamp
    • CString ISO date
    • DObjectId value

    Why this is the answer

    TTL index deletion requires a BSON date or an array of BSON dates. Unix integers, strings, and ObjectIds cannot be used with the TTL monitor.

Frequently asked questions

Everything about the MongoDB Certified Associate Database Administrator question bank and how to use it.