syncIndex option to hide instead of drop index #14868
Labels
enhancement
This issue is a user-facing general improvement that doesn't fix a bug or add a new feature
new feature
This change adds new functionality, like a new method or class
Milestone
Prerequisites
🚀 Feature Proposal
I love the syncIndex() feature that helps to have a single source of truth for our MondoDB schema indexing.
However, dropping an index is never 100% sure, especially on large MongoDB databases with large codebase querying the collections. There can be some rarely used piece of code that need once a time an index and thus will not update the $indexStats frequently enough to identify that this index is actually needed.
One recommandation from the MongoDB team is to hide an index before actually dropping it. It will exclude the index from the query planner options and whenever you identify a performance issue due to this exclusion, you can instantly make it visible again. This is way faster and less resource consuming than re-creating the index from scratch. The latter can last for hours on large collections and your system suffers during this re-creation.
It would be nice to pass an option to the syncIndex({hide: true}) to hide the indexes missing in the schema instead of dropping them immediately. Once the system has run for a certain period of time without problem, then we can call the syncIndex({hide:false}) to actually drop them.
Motivation
Secure the synchronization of the indexes and prevent mis-dropping of rarely used indexes with immediate rollback if necessary.
Example
The text was updated successfully, but these errors were encountered: