-
Notifications
You must be signed in to change notification settings - Fork 32
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
Optimize user, role and organizations SQL queries #948
Conversation
4ee83a3
to
ffae7be
Compare
ca27c9b
to
114affc
Compare
256bd7c
to
82a8fa8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a70d1d5
to
f890ad4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, select_related is a great choice when it comes to looking up foreign key relations 🚀
Maybe we could use a similar approach for the user groups relationship?
But that could be the next iteration, if at all needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefetching the groups and role objects reduced the amount of queries even further: Instead of doing two additional queries for each user to retrieve the groups and the role of the user, this does now two queries in the beginning to get the groups and roles for all users at once, so a constant number of queries independently from the number of users in the database. 🎉
I'll rebase after the XLIFF PR is merged. |
The PR is merged, I guess you can rebase it now :) |
7df7b32
to
89ebfd7
Compare
- Select user organization along with user data. - Combine group and role queries into one to improve performance. - Prefetch group and role objects in user list Co-authored-by: Timo Ludwig <ludwig@integreat-app.de>
89ebfd7
to
899050a
Compare
This PR aims at creating a checkbox at "users" in #943
Sadly, AFAICT there is not that much performance to gain here.