I was wondering how we could usually optimize the database performance for a data intensive web application. Are there any common requirements like what queries to use, how to deal with relationships fast, whether to avoid writing to database as much as possible, etc. Anything related works.
Or more specifically, any techniques to make the Ruby on Rails database more efficient?
Thanks a lot!
Start of by analyzing your bottlenecks, NewRelic is a great tool to help you with that.
To increase read performance adding indexes, eager loading and caching are the low hanging fruit. Check out https://github.com/flyerhzm/bullet to help you with eager laoding and removing N+1 queries.
Speeding up writing is usually more tricky. Moving to queues can defiantly help and usually fairly straight forward to implement. Checkout https://github.com/defunkt/resque and https://github.com/mperham/sidekiq