-
Notifications
You must be signed in to change notification settings - Fork 7
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
Reduce 298 SQL queries which are needed for a profile #1079
Comments
The problem here is with the User resource. Specifically the preparation block. IMO resources shouldn't have a default preparation with a load unless the calculation/aggregate being loaded is necessary and does not read from the database. These load statements should be left to the caller to add what it needs.
In our case both, credit_points, profile_photo, city and roles make additional sql queries to load the data. |
I liked the idea of having a BasicUser resource, which is very minimal and does not have any default load statement and the having the User one with any number of load statements and limiting when the user should be loaded from it. |
Something else, I think the genserver |
I agree , before we make this refactor , I think we need to have basic tests for at least each live view and resource as so mantypages and actions are dependent on the loaded resources on the user. |
I think it will be faster to start on a green field with this problem. See #1080 @briankariuki You are point on this one. Please keep us in the loop with information by adding updates in that issue. I kind of hope that this should be doable quite fast. But in case it takes more than two weeks contact me and we discuss it. |
My setup:
I fire up the browser and open a profile page. That moment the
iex
displays no less than 919 rows of messages. I counted 298 SQL queries which need a total of 143 ms on my MacBook Air. Just the SQL queries use 143 ms!!!This is going to kill us in the long run. We need to reduce the number of database hits. Why do we need 298 SQL queries to display just one profile?
@briankariuki Since you are already working at this. Can you share some light on the problem? How can we tackle this? What are our options?
CC @MICHAELMUNAVU83 @Kimutai01 Feel free to add thoughts to this ticket too.
Here are the queries for just one profile page:
The text was updated successfully, but these errors were encountered: