-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make autoIndex syncIndex instead of createIndex #14602
Comments
You can use We won't make autoIndex use |
@hasezoey @AbdelrahmanHafez what do you think, is it worthwhile to add a separate option to make |
Personally, i dont mind if there would be a extra option to use syncIndexes instead, as long as it is not the default for |
Well, the semantics of auto index is "mongoose will take care of index for you". But this isn't true simply because this option should never be used in production (as stated in current docs) as it tries to recreate indexes as many times as possible. As this should not be used in production, the change of behaviour would not break previous code. |
@hasezoey what do you think about using syncIndexes by default in Mongoose 9? I think syncIndexes is what apps should use by default, but switching is risky because syncIndexes could cause some serious performance issues for production apps if it drops an index that it shouldn't |
i cannot really say for the impact on performance as i usually at most run personal stuff, but i think it is the behavior that would likely be expected of the |
Hi all, late to the party. While I agree in principle that It's easy to think that Also, the explicit execution gives users finer control over when they want to sync their indexes, and whether or not they want to What do you think? |
Thanks for reminding us about the discussion in #11030 @AbdelrahmanHafez , the potential for race conditions in So requiring calling |
Prerequisites
馃殌 Feature Proposal
autoIndex will check existing indexes instead of re-creating indexes everytime the app runs
Motivation
Mongoose docs explains that autoIndex is not advised to production environments because it creates indexes everytime the app runs. This makes the process of introducing indexes tricky in production. Mongoose offers synIndexes, but this has to be called individually for each model.
Example
No response
The text was updated successfully, but these errors were encountered: