Back to Practice

Practice · Interview · Card 3

"How do you find and fix an N+1 query?"

Every Rails interview asks this. The naive answer names includes and stops. The senior answer covers both halves of the question.

The question

"You suspect a view has an N+1. How do you confirm it, and how do you fix it?"

Your job

The question has two halves. Most candidates answer only the fix. Form an answer that covers both — diagnosis and fix — with concrete tools named.

Take a moment. Name three ways you'd confirm the N+1. Then name three variants of the fix and when you'd pick each. Bonus: how would you measure it in production.