Ctrl K
Python · Mid-level · Theory

The order list page in the Django admin takes ten seconds to load, and the logs show hundreds of SQL queries per page load. What's going on, and how do you fix it?

~4 min by voice

How to approach it

The interviewer wants to see whether you recognize the N+1 problem in the Django ORM from its symptoms, understand the mechanism of lazy loading of relations, and can fix it systematically and keep it from coming back: select_related/prefetch_related, diagnostic tools, tests on the number of queries.

Have you seen this question in a real interview?
Answers0
Avg. score—
Strong—
Practiced0
Topics
Similar questionsA Django monolith can no longer keep up with growing traffic. How would you design how it runs in production: the application server, the worker model, the number of workers, and working with the database? Mid-levelDesign 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? SeniorThe 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? Mid-levelYou have a large Django monolith, and the team wants to rewrite it in FastAPI for async and performance. How would you make this decision, and how would you carry out the change? SeniorWhat is the N+1 query problem in an ORM, and how do you solve it in Django? Junior

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