Answer the question
In order to leave comments, you need to log in
Why does yii2 take such a long time to generate templates?
drove, means zatestit this business without caching. So the generation of data for the template takes about 0.06c. Too much of course, but tolerable. But the template with ListView and other standard widgets builds the page already 0.220c on average (for 30 news, a la blozhik). How so? They are positioning themselves as superfast?! How to speed it up? (without caching, so that it is less than 0.1c, at least 0.099)
Answer the question
In order to leave comments, you need to log in
They are positioning themselves as superfast?!
To begin with, look at what the debug panel displays
How much memory it consumes, how many queries it makes to the database.
1) If the number of requests goes off scale (>> 10) check whether all related data has been connected.
For example
News::find()
->with([
'author.profile',
'category',
'comments',
// И остальные
])
->limit(30)
->all()
SELECT * FROM author WHERE id = 1;
SELECT * FROM author WHERE id = 2;
SELECT * FROM author WHERE id = 5;
News::find()
->with([...])
->asArray()
->limit(30)
->all()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question