Answer the question
In order to leave comments, you need to log in
Is it normal to have a large number of database queries in Yii2?
I'm doing a project in Yii2. Before that, I used QueryBuilder in projects, but now I decided to try ActiveQuery and it is not undoubtedly more convenient. But I noticed that on almost all pages there are a large number of calls to the database. (See screenshot)
Judging by the debugger, they do not take much time.
The news page displays categories of news, and a list of two news items. Plus pictures are uploaded.
Tell me if this is normal for Yii2? Or it is necessary to optimize requests?
Answer the question
In order to leave comments, you need to log in
No, it's not normal. A large number of requests is bad and this behavior should be eliminated. Most likely you have a large number of queries due to the following reasons
1. Database schema caching is not enabled. Accordingly, you need to enable
it
2. Eager data loading is not used
22 requests is nothing. But here the question is not in quantity as such, but in optimality. We need to see what these queries are and whether they can be reduced, combined, cached, etc.
Be sure to read this: www.yiiframework.com/wiki/834
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question