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 raiseload option for all queries #13311

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

di
Copy link
Member

@di di commented Mar 27, 2023

Sort of towards #3081.

This PR turns on the raiseload option by default for all queries, essentially making N+1 queries impossible in our codebase, and requiring explicit loads instead, rather than per-query as documented in https://docs.sqlalchemy.org/en/20/orm/queryguide/relationships.html#preventing-unwanted-lazy-loads-using-raiseload .

Marking this as draft for now because there are a lot of test failures to address. I'm also not entirely sure yet if this also covers deferred columns as well, because that seems to be a separate setting: https://docs.sqlalchemy.org/en/20/orm/queryguide/columns.html#using-raiseload-to-prevent-deferred-column-loads

@ewdurbin
Copy link
Member

Question: Is there a way to approach this gradually? Perhaps via Warnings?

Request: Can you implement a couple of the necessary fixes as examples? You mentioned that there might be some impacts on code readability. If its too egregious it may not be worth it.

@miketheman miketheman added the blocked Issues we can't or shouldn't get to yet label Apr 24, 2023
@miketheman
Copy link
Member

Let's pursue this once we've upgraded db libs. see: #13497

@di
Copy link
Member Author

di commented Apr 3, 2024

@miketheman Do you think we're ready to revisit this?

@miketheman
Copy link
Member

@di I think this is worthwhile, but should probably come after #15634 - since I was trying to ensure a query count before/after to support this effort from a web-side, since many of our potential N+1 come from HTML template rendering iteration loops.

@di
Copy link
Member Author

di commented Apr 3, 2024

OK! Let's say this is blocked on #15634.

@miketheman
Copy link
Member

OK! Let's say this is blocked on #15634.

unblocked now that we can count queries emitted when loading a page via webtest

@miketheman miketheman removed the blocked Issues we can't or shouldn't get to yet label Jul 12, 2024
@di
Copy link
Member Author

di commented Jul 12, 2024

Rebased. Quite a number of test failures to work through here if anyone is feeling up for it 🙂

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.

3 participants