Concept Flow - Database query optimization
Write ActiveRecord query
Rails builds SQL query
Send SQL to DB
DB executes query
Return results
Render or use data
If slow, analyze query
Add indexes or optimize query
↩Back to Write ActiveRecord query
This flow shows how Rails turns your code into SQL, runs it, and how you optimize by analyzing and improving queries.