Skip to content

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