简体   繁体   中英

Slow activeadmin index page

I have Rails 5 with active admin gem working. In development I saw a lot of queries when run with rail s . Most of them are of type CACHE(0.0ms) . Finally after some seconds it shows:

 Rendered /home/blabla/.rvm/gems/ruby-2.2.5@test/gems/activeadmin-1.0.0.pre4/app/views/active_admin/resource/index.html.arb (10588.9ms)
Completed 200 OK in 10646ms (Views: 10338.2ms | ActiveRecord: 264.1ms)

Is the render view time the problem? In the index view I show a lot of information about some model an its associations. Also I add scoped_collection method with some includes for eager loading, but it is the same, It is tooo slow.... I appreciate any help...

Thank you!

This is likely due to the filters. You can specify the filters you want to include, otherwise all attributes on the model will be added as a filter. https://github.com/activeadmin/activeadmin/blob/master/docs/3-index-pages.md .

The CACHE ones are fine. This means that ActiveRecord already has the data and has not needed to do a DB call.

To diagnose the problem, I'd recommend the bullet gem , which will highlight slow queries caused by missing includes for you. To really drill down into performance, you could try the rack mini-profiler gem with the flamegraph extension. I've had success with these in diagnosing the issues causing the slownewss. Often it's an N+1 issue, but also the development version will recompile all the CSS every time you make an edit.

Speeding up ActiveAdmin by using includes is pretty simple:

controller do
  def scoped_collection
    super.includes(:bill_address)
  end
end

Be aware that rendering in production will not include compiling assets on the fly, so this can be significant in development but not really an issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM