Ctrl K
Backend · Mid-level · Theory

The orders list page has started taking several seconds to load, and in the logs you see hundreds of near-identical SQL queries per HTTP request. What's going on, and how would you fix it?

~4 min by voice

How to approach it

This checks whether you recognize the N+1 problem from its symptoms, understand how it arises in an ORM, and can fix it systematically: confirm it by measuring, choose between a JOIN and batch loading, and protect against regressions.

Have you seen this question in a real interview?
Answers0
Avg. score—
Strong—
Practiced0
Topics
Similar questionsA query that used to run in milliseconds now takes seconds after the table grew to tens of millions of rows. How would you investigate, and what can you do about it? Mid-levelWhat are a primary key and a foreign key? And how would you model a many-to-many relationship, for example students and courses? JuniorDesign how a high-load Python service using SQLAlchemy works with PostgreSQL: dozens of instances, each with several workers. How would you organize the connection pools and the session lifecycle? SeniorYou join the orders table with the payments table, and the total revenue in the report suddenly grows almost threefold. How would you look for the cause, and how would you fix it? Mid-levelTell me about a time you denormalized a data model for the sake of performance. What price did you have to pay for it? Senior

Answer by voice

The interviewer will ask this question and listen. Think out loud and ask for a hint if you need one. When you're done, pause or tap “That's my answer”. In about a minute, your score and the points you covered show up here.

Sign in to answer

Best with headphones · ~4 min