Consider a MongoDB collection with a TTL index set to expire documents 3600 seconds after the createdAt field. What is the expected output after the TTL monitor runs?
db.collection.find({})Think about what TTL indexes are designed to do automatically in MongoDB.
TTL indexes automatically remove documents after the specified time has passed since the indexed date field. This helps in auto-expiring data without manual deletion.
Choose the correct MongoDB shell command to create a TTL index on the timestamp field that expires documents after 24 hours.
Look for the correct option name for the expiration time in the index options.
The correct option to specify expiration time in seconds is expireAfterSeconds. The method is createIndex.
You have a collection with a TTL index on createdAt and very high write volume. Which approach optimizes TTL index performance?
Consider how sharding and indexing affect write performance and TTL expiration.
Sharding by the TTL indexed field helps distribute writes and TTL deletions evenly, improving performance. Multiple TTL indexes or compound indexes can cause overhead.
A TTL index was created on expireAt with expireAfterSeconds: 0, but expired documents remain. What is the likely cause?
Check the data type and presence of the indexed field in documents.
TTL indexes require the indexed field to be a valid date type and present in documents. If missing or wrong type, TTL deletions won't occur.
In MongoDB, when using clustered collections, how does TTL index behavior differ compared to regular collections?
Think about how clustered collections organize data and index requirements.
TTL indexes on clustered collections require the TTL field to be the clustered key because the data is organized by that key. This ensures efficient expiration.