Skip to content
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

Inefficient column deletion #6815

Closed
4 tasks done
mtrezza opened this issue Jul 20, 2020 · 0 comments · Fixed by #6823
Closed
4 tasks done

Inefficient column deletion #6815

mtrezza opened this issue Jul 20, 2020 · 0 comments · Fixed by #6823
Labels
type:feature New feature or improvement of existing feature

Comments

@mtrezza
Copy link
Member

mtrezza commented Jul 20, 2020

We use GitHub Issues for reporting bugs with Parse Server.

Make sure these boxes are checked before submitting your issue - thanks for reporting issues back to Parse Server!

  • This isn't a vulnerability disclosure, if it is please follow our security policy.

  • You're running version >=2.3.2 of Parse Server, we can't accept issues for very outdated releases, please update to a newer version.

  • This isn't a question, if you need if you have questions about code please use Stack Overflow with the parse-platform tag & other questions can be posted on the community forum.

  • You've searched through existing issues, your issue may have been reported or resolved before.

Issue Description

Removing a column from a class via Parse Dashboard is inefficient and can potentially impact a production system.

A column is removed by calling updateMany (for the MongoDB storage adapter) on the entire collection which is a simple but inefficient way to delete a field. It causes a collection scan through all documents, even if only 1 document has the field which should be removed.

.then((collection) => collection.updateMany({}, collectionUpdate))

Steps to reproduce

  1. Create a collection with millions of documents.
  2. Delete a column via Parse Dashboard.
  3. Notice the DB impact.

Expected Results

Deleting should make use of indices. This would only update the document that actually contain the field to remove.

Actual Outcome

Deleting does not make use of indices and causes collection scan.

Suggested solution

Add query filter to updateMany command to allow for index scan:

  • For an index to be used when deleting a field, it has to be manually created (auto-creating an index can impact a production system if not properly prepared).
  • The required index to create is: { <fieldNameToDelete>: { $exists: true } }.

Possible Improvements

The index could be temporarily created and deleted afterwards, however this would need to be optional in the Parse Dashboard since index creation itself can also have a performance impact on the DB.

Environment Setup

  • Server
    • parse-server version (Be specific! Don't say 'latest'.) : 4.2.0
@mtrezza mtrezza added type:feature New feature or improvement of existing feature and removed type:improvement labels Dec 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature New feature or improvement of existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant