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

[#8093] Fixes performance of update validator, and flatten function logic #8192

Merged
merged 2 commits into from
Sep 26, 2019

Conversation

birdofpreyru
Copy link
Contributor

Fixes #8093

Before this commit the flatten(..) function failed to deliver what it promised. Namely, it entered into Mixed paths of objects.

The update validator, on its side, did not pass the casted doc schema into flatten(..). If the casted doc contained a large Mixed field, all its paths were added into the list of updated paths. They were later ignored by now removed check for schemaPath type, but performance was already hurt.

This commit makes sure that inner sub-paths of Mixed paths are not included into the array of paths at all, thus no further checks of that are necessary, and the performance is restored.

…function logic

Before this commit the `flatten(..)` function failed to deliver what it
promised. Namely, it entered into Mixed paths of objects.

Update validator, on its side, did not pass the casted doc schema into
`flatten(..)`. If the casted doc contained a large Mixed field, all its
paths were added into the list of updated paths. They were lated ignored
by now removed check for schemaPath type, but performance was already
hurt.

This commit makes sure that inner sub-paths of Mixed paths are not
included into the array of paths at all, thus no further checks of that
are necessary, and the performance is restored.

Fixes Automattic#8093
Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great find, thank you very much for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

runValidators: true for findOneAndUpdate is orders of magnitude slower than save().
2 participants