You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Assume there are 20 posts in the result
<% @posts.eachdo |post| %><%= @post.title %>#First level attribute
<% @posts.comments.each do |comment| %><%= @comment.saywhat %> <% end %><% end %>
If I keep the has many relations in the model, 20 posts on the page render in about 10-15 seconds with say 3 - 4 comments each at average.
If I remove the has many relations, all 20 posts load within 1 - 2 seconds. What I wanted to understand was is this expected to behave this way? I mean is the time taken to parse has many relations so much or I am doing something wrong?
Are others facing similar latencies?
The text was updated successfully, but these errors were encountered:
No, there is only one initial request that goes and returns the results. The initial request returns the post along with the 'has many' comments, that's how we have built the service also which is returning the posts along with the comments embedded. In the view we have to run a for each for the comments and I am sure it does not make more requests for those comments. The HER results already has the comments.
When trying to use has many relations for a model , the page loads increases drastically.
Consider this example -
In the controller the same is fetched like
In the view -
If I keep the has many relations in the model, 20 posts on the page render in about 10-15 seconds with say 3 - 4 comments each at average.
If I remove the has many relations, all 20 posts load within 1 - 2 seconds. What I wanted to understand was is this expected to behave this way? I mean is the time taken to parse has many relations so much or I am doing something wrong?
Are others facing similar latencies?
The text was updated successfully, but these errors were encountered: