Get the latest tech news
Optimize Database Performance in Ruby on Rails and ActiveRecord
Let's dive into some strategies to optimize database performance in Rails and ActiveRecord.
Although SQL databases are very efficient, as our growing customer base puts an increasing load on our servers, we begin scaling our instance counts, workers, etc. This can quickly spiral out of control, resulting in a staggering number of queries and causing serious consequences such as crashed pages, an exhausted database connection pool, and memory running out, ultimately grinding our site to a halt. As you're probably aware, indexes are special data structures (typically B-trees) that a database uses to quickly find records, improving retrieval times from O(n) to O(log(n)).
Or read this on Hacker News