Powerful Data: Making Rails Apps Faster with Aggregation
summary
Dashboards slow because Rails pulls data into Ruby for joins and math; moving summaries into aggregate tables and using ActiveRecord’s group or hand-written raw SQL pushes work to the database and removes joins. Concrete wins: a 15s query becomes ~100ms (~150x), a 90s query drops to 4s (≈2143%), and a nightly job falls from ~4+ hours to under 1 hour by removing one index and adding two composite indexes. Use EXPLAIN, benchmark.measure, and a production-scale DB clone to validate changes.
AI-written summary · about
chapters (20)
- 0:00Powerful Data in Rails
- 1:49Dashboard challenges with large datasets
- 2:54Aggregation and query speed
- 4:17Efficient aggregate models
- 5:19Trade-offs of aggregate tables
- 6:21Rails vs database aggregation
- 9:30Limitations of Rails group
- 10:33Raw SQL for aggregations
- 12:41Risks of raw SQL
- 14:04Database indexes for performance
- 15:47Indexes and background jobs
- 16:50Test coverage importance
- 17:54Pipeline performance benefits
- 18:57Recommendations and call to action
- 19:59Q&A on aggregate tables
- 20:41Multi-resolution dashboard data
- 21:42Reusable vs custom aggregations
- 22:03Benchmarking Rails queries
- 23:07Aggregation vs materialized views
- 23:28Accurate benchmarking
related talks
58mPanel Discusion - Performance problems in Rails applications
41mUsing Databases to Pull Your Application Weight
14mDatabase Performance at Scale for RoR Applications
31m"Optimizing SQL Queries"
31mProcessing data: Ruby or SQL?
26mRails Performance Monitoring 101: A Primer for Developers
40mLevel-up Your ActiveRecord Skills: Learn SQL!
21mBuilding a Performance Analytics Tool with ActiveSupport
