-
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
Refactor live "/:username", ProfileLive #1004
Comments
Code readability is a major point too. Since the application is online now more people look into the code. They should have a chance to understand it. |
Let me investigate what's causing the issue. I'll add the findings here before attempting to fix it |
The first issue I've noticed is the read :by_user_id action on the Story resource. I can go ahead and refactor the Story resource not to load the user or do it on the profile_stories_live.ex where we fetch the stories and use the :read action and preload only what we need to display that page. @wintermeyer what do you think? |
The second issue I found is that the UserFlags resource also preloads the user. |
I can't say much about it because I am not deep in the code. I just see all the SQL queries in the log and always think "this can not be the optimal way of doing it". Within the Phoenix world SQL queries are expensive (at least 9 out of 10 times). I am saying this because I used to program a lot with Ruby on Rails and there SQL was much cheaper than Ruby. But for us normal Elixir is cheaper than multiple SQL queries. Bottom line: Do what makes most sense for you to get more speed and improve readability (hoping that both come together). In case you have to make a choice between speed and code readability I tend to go into the code readability direction. |
In my opinion the |
@briankariuki Please do me a favour and set the |
Feed the database with the demo users and load a
/:username
page in your browser. Have a look at the millions of SQL queries which are triggered by that page.I am sure that there is a massive potential to DRY that code and to improve it. No need to load the same data over and over again from the database.
@briankariuki Please do create sub issues when it makes sense. I prefer small and quick over big PRs since everybody else is working on the same code.
PS: Please add a before/after time when possible. I would like to get a feeling how much performance we gain with this issue.
Tasks
The text was updated successfully, but these errors were encountered: