Answer the question
In order to leave comments, you need to log in
How to optimize haml render speed?
Hello! The page on haml is rendered almost 200ms. For comparison, queries to the database are completed in 6ms.
I tried to rewrite to slim, the result became smaller, but not much. Through experiments, I found out that most of the time is occupied by an each-loop through elements from the database (ActiveRecord_Relation ). There are exactly 50 of these elements on one page.
Even if only the basic information about each record is displayed inside each, the cycle is very long
. Is this a normal situation? How to speed up page rendering?
Answer the question
In order to leave comments, you need to log in
apidock.com/rails/ActiveRecord/QueryMethods/includes
Try this
You can, as Anton Radushevsky wrote , but it's better to get all the data in advance in the controller (50 pieces), and only insert them in the view. Then there will be no DB call costs inside the HAML template loop.
Maybe this is the point?)) How to speed up the rendering of nested simple_fields_for fields?
I made caching of a part of the template with a table, it became an order of magnitude faster, of course, but still not happy.
I really like RoR, writing on it is pure pleasure.
But is it normal for a table of 50 elements to render in 200ms? Is he really that slow? And this despite the fact that requests to the database take less than 5ms. The cycle definitely does not create additional requests
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question