-
-
Notifications
You must be signed in to change notification settings - Fork 4k
syncIndex option to hide instead of drop index #14868
Copy link
Copy link
Closed
Labels
enhancementThis issue is a user-facing general improvement that doesn't fix a bug or add a new featureThis issue is a user-facing general improvement that doesn't fix a bug or add a new featurenew featureThis change adds new functionality, like a new method or classThis change adds new functionality, like a new method or class
Milestone
Metadata
Metadata
Assignees
Labels
enhancementThis issue is a user-facing general improvement that doesn't fix a bug or add a new featureThis issue is a user-facing general improvement that doesn't fix a bug or add a new featurenew featureThis change adds new functionality, like a new method or classThis change adds new functionality, like a new method or class
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