MongoDB Questions and Answers Part-30

1. Point out the correct statement.
a) TTL indexes expire documents after the specified number of seconds has passed since the indexed field value
b) TTL indexes are special compound indexes
c) If a document does not contain the indexed field, the document will expire
d) None of the mentioned

Answer: a
Explanation: The expiration threshold is the indexed field value plus the specified number of seconds.

2. Secondary members replicate _________ operations from the primary.
a) Update
b) Drop
c) Insert
d) None of the mentioned

Answer: d
Explanation: On replica sets, the TTL background thread only deletes documents on the primary.

3. You cannot use _________ to change the value of expireAfterSeconds of an existing index.
a) createIndex()
b) dropIndex()
c) removeIndex()
d) none of the mentioned

Answer: a
Explanation: Instead use the collMod database command in conjunction with the index collection flag. Otherwise, to change the value of the option of an existing index, you must drop the index first and recreate.

4. You cannot create a TTL index on a ________ collection.
a) Sharded
b) Capped
c) Primary
d) None of the mentioned

Answer: b
Explanation: MongoDB cannot remove documents from a capped collection.

5. Point out the correct statement.
a) MongoDB uses a locking system to ensure data set consistency
b) If certain operations are long-running or a queue forms, performance will degrade as requests and operations wait for the lock
c) Long queries can result from ineffective use of indexes
d) All of the mentioned

Answer: d
Explanation: Lock-related slowdowns can be intermittent.

6. ________ provide the number of times the lock acquisitions encountered deadlocks.
a) locks.deadlock
b) lock.deadlockCount
c) locks.deadlockCount
d) all of the mentioned

Answer: c
Explanation: The globalLock data structure contains information regarding the database’s current lock state, historical lock status, current operation queue, and the number of active clients.

7. If __________ is high relative to uptime, the database has existed in a lock state for a significant amount of time.
a) globalLock.halfTime
b) globalLock.totalTime
c) globalLock.downTime
d) all of the mentioned

Answer: b
Explanation: The value of totalTime represents the time, in microseconds, since the database last started and creation of the globalLock.

8. The __________ data structure value provides more granular information concerning the number of operations queued because of a lock.
a) currentQueue
b) curQueue
c) currentQu
d) none of the mentioned

Answer: a
Explanation: The serverStatus command returns a document that provides an overview of the database process’s state

9. serverStatus includes all fields by default, except _________
a) rangeDeleter
b) rangeDelete
c) rangeDEL
d) none of the mentioned

Answer: b
Explanation: You may only dynamically include top-level fields from the serverStatus document that are not included by default.

10. ______ field contains total number of current clients that connect to the database instance.
a) available
b) current
c) always avail
d) none of the mentioned

Answer: b
Explanation: available contains the total number of unused connections available for new clients.