Skip to content

Improve perf of Document.save #2049

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

Merged
merged 4 commits into from
Jun 1, 2019

Conversation

bagerard
Copy link
Collaborator

@bagerard bagerard commented May 11, 2019

Document.save is currently making 2 calls to to_mongo (before and after validation), this is expensive when objects are very large. Since the first call was only used to identify if the document is created or updated, we could restrict the call with to_mongo(fields=['id'])

@bagerard bagerard force-pushed the save_to_mongo_call_in_save branch from 6cd6f10 to 8fe0a16 Compare May 26, 2019 20:34
@bagerard bagerard changed the title Improve perf of Document.save Improve perf of Document.save [WIP] May 27, 2019
@bagerard bagerard force-pushed the save_to_mongo_call_in_save branch from 8fe0a16 to b92ede0 Compare June 1, 2019 09:14
@bagerard bagerard force-pushed the save_to_mongo_call_in_save branch from b92ede0 to 5fb0f46 Compare June 1, 2019 09:16
@bagerard bagerard changed the title Improve perf of Document.save [WIP] Improve perf of Document.save Jun 1, 2019
@bagerard
Copy link
Collaborator Author

bagerard commented Jun 1, 2019

@wojcikstefan @erdenezul Could you have a quick look at this when you have a chance?

@erdenezul
Copy link
Collaborator

nice work man

@bagerard bagerard merged commit a18c8c0 into MongoEngine:master Jun 1, 2019
@bagerard bagerard deleted the save_to_mongo_call_in_save branch June 2, 2019 21:15
@wojcikstefan
Copy link
Member

I'm a little late to the party, but this indeed looks very good. Thanks @bagerard!

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.

4 participants