Skip to content

syncIndex option to hide instead of drop index #14868

@vvandens

Description

@vvandens

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the feature has not already been requested

🚀 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

model.syncIndex({hide: true}); // hide missing schema indexes instead of dropping them
model.syncIndex(); // actually drop missing schema indexes. Same as {hide:false}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementThis 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 class

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions