-
Notifications
You must be signed in to change notification settings - Fork 101
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
do not use $ne operator #50
Comments
assume I had the following documents, the documents were producted before I use mongoose-delete plugin,
and now I start to use this plugin, because it use |
True, but if your collection has 1,000,000 docs instead of 3, a query that does not filter them out by an index will timeout. And this can get unpredictable as it will happen in some collections and it won't in others. |
Until proposing a pull request, a quick fix is: That supposed that "deleted" always exist, which is the case in my database |
It is in pull request |
This type of changes can affect existing users and I really try to keep back compatibility with older versions. This is the main reason why I introduce new option This new option will cover both scenarios. https://github.com/dsanel/mongoose-delete/blob/master/test/index.js#L1598-L1654 Hope this will help @gabzim? ;) |
In large collections, the
$ne
operator is very inefficient and can make queries slow. (https://docs.mongodb.com/manual/reference/operator/query/ne/ last paragraph).I recently had to investigate performance troubles we're having in one of our largest collections and it's due to the use of this plugin. What I'd suggest is maybe always keeping
deleted
asfalse
and then doing{$eq: false}
to retrieve active documents.The text was updated successfully, but these errors were encountered: