What method do you use to hide an index?

Prepare for the MongoDB Associate Developer Exam with flashcards and practice multiple choice questions. Each question includes hints and explanations to ensure you're ready for test day.

Hiding an index in MongoDB allows you to temporarily prevent the query planner from considering an index for query execution while still keeping the index available for future use. The method that achieves this is db.collection.hideIndex(), which specifically updates the index's visibility status.

When an index is hidden, it will not be used for query planning, ensuring that queries resort to other indexes or collections as necessary. This capability can be very useful when you're experimenting with query performance or when you want to deactivate an index without physically dropping it.

The other methods mentioned do not fulfill the purpose of hiding an index. For instance, removing an index with db.collection.removeIndex() completely deletes the index, while db.collection.setIndexVisibility() does not exist as an operational function in MongoDB. Similarly, db.collection.updateIndex() is not a valid command, which confirms that db.collection.hideIndex() is indeed the correct choice for the task of hiding an index.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy