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

Use Session.get() in get_instance instead of Session.query() #548

Merged
merged 2 commits into from Jan 7, 2024

Conversation

zippolyte
Copy link
Contributor

@zippolyte zippolyte commented Dec 30, 2023

Session.get() (SQLA docs) tries to fetch an object from the session's identity map if it exists, and performs a SQL query otherwise.

This improves load() performance by reducing number of SQL queries, especially for nested relationships, if everything is already available into the session.

@zippolyte zippolyte marked this pull request as ready for review December 30, 2023 17:20
Session.get() tries to fetch an object from the session's identity map if it exists, and performs a SQL query otherwise.

This can help improve load performance by reducing number of SQL queries, especially for nested relationships, if everything is already available into the session.
@sloria
Copy link
Member

sloria commented Jan 7, 2024

TIL about Session.get. Thanks for this PR!

@sloria sloria enabled auto-merge (squash) January 7, 2024 22:13
@sloria sloria merged commit 7570f00 into marshmallow-code:dev Jan 7, 2024
7 checks passed
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.

None yet

2 participants