How to optimize database read operations in Ruby on Rails