Diagnosing N+1 Queries in Yii2 ActiveRecord and Fixing Them with Eager Loading
A Yii2 list page shows one query for the parent models plus one query per row for each accessed relation. Diagnose it with the debug toolbar, confirm lazy loading in loops, then fix with with() for batched IN queries or joinWith() for filtering, plus indexes and selective selects.