"Optimizing SQL Queries"
summary
Application code causes most slowdowns (about 90% vs 10% for webserver); queries under 10ms are often network/IO bound, queries over 50ms are true slow paths. Practical fixes: use Rails features like inverse_of and counter_cache, prefer a unique index instead of validation queries, add domain conditions (site_id, date ranges) to steer index choice, and cache higher when needed with key‑value stores and ETag/versioned responses. Watch out: indexes can eat ~70% of DB size. A triple‑nested SELECT for leaderboard ranking proves fast in practice.
AI-written summary · about
chapters (8)
- 0:00Introduction and welcome
- 4:20Why optimize SQL queries
- 7:13Avoiding unnecessary queries
- 11:56Optimizing with indexes
- 15:55Caching tables and data
- 21:14Query execution plans
- 25:31High-level caching strategies
- 30:00Optimization steps summary
related talks
25mPowerful Data: Making Rails Apps Faster with Aggregation
42mHolistic Database Application Tuning
41mUsing Databases to Pull Your Application Weight
14mDatabase Performance at Scale for RoR Applications
33mBetter Rails by Knowing Better Database by Ding ding Ye
31mUsing Databases to pull your applications weight
24mFrom Expensive Queries to Smart Caching: A DBA’s Guide for Rails
33mCache is King: Get the Most Bang for Your Buck From Ruby
