DEV Community

Cover image for Reports performance improvement
fedeagripa
fedeagripa

Posted on

Reports performance improvement

Are you tired of fighting with the performance of your reports and overloading your database?

Fight
Well, here I bring you a really simple Rails 6 solution!

  • Use new Rails6 Multiple Databases configuration
    To do so you can check my other post

  • Switch your reports to use the replica database

As an extra you can also use readonly_slow:

ActiveRecord::Base.connected_to(database: { readonly_slow: :replica }) do
  # runs a long query while connected to the +replica+ using the readonly_slow role.
  User.run_a_huge_query
end
Enter fullscreen mode Exit fullscreen mode
  • Voila, that's all! voila

Top comments (0)