Skip to content

Inefficient column deletion #6815

Closed
@mtrezza

Description

@mtrezza

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:featureNew feature or improvement of existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions