Technical Senior Level

You notice an API endpoint backed by Doctrine is slow. Walk me through how you would diagnose and fix the performance issues.

Quick Tip

Lead with the profiler: "I open the Symfony debug toolbar, check the Doctrine panel. If I see 50 queries for a list of 50 items, that is an N+1 problem. I add a fetch join in the repository query and it drops to 1."

What good answers include

Systematic approach: enable the Symfony profiler and check the Doctrine panel for query count and timing. Common issues: N+1 queries (fix with DQL joins or fetch joins), missing database indexes, hydrating full entities when a DTO projection suffices, excessive flush operations, and lazy-loading in loops. Solutions: use QueryBuilder with addSelect for eager loading, use NEW DQL syntax for DTO hydration, add indexes via Doctrine attributes, batch operations with iterate(), and consider read replicas. Strong candidates mention the debug toolbar query count as the first diagnostic step.

What interviewers are looking for

Senior Symfony question. Developers who cannot diagnose N+1 queries will build slow applications without knowing why. Those who jump to caching before fixing the query layer are masking the problem.

← All Symfony questions