Loading…
0+ curated questions with the same answer shape every time: quick recap, deep dive, pitfalls, and follow-ups. Coverage includes .
Active Record query performance is the most common Rails production problem and the most-tested topic in senior interviews. This module covers the N+1 query problem (diagnosis with Bullet gem, strict_loading!, and SQL log analysis), the three solutions (includes — auto-chooses strategy, preload — always a separate IN query, eager_load — always a LEFT OUTER JOIN needed when WHERE references the association), Arel for programmatic query building, find vs find_by vs where.first performance difference, find_each and find_in_batches for batch processing, pluck vs select (pluck skips AR object instantiation), exists? vs any? vs count, update_all vs looping, and EXPLAIN ANALYZE via to_sql. Every answer shows the SQL generated and the decision tree.
Full catalog
Topics are ordered for learning. Within each topic, rows are numbered 1–0 globally so you always know where you are. Collapse topics if you want a lighter view — use Expand all when you need the full list again.
Numbers 1–0 follow the order we recommend — click any row to open the full answer, or use the sticky Next link at the bottom of each page to go Q1 → Q0.