[size=“2”][size=“3”][size=“2”][size=“3”][size=“3”][size=“5”][size=“4”][font=“Arial”]Hello to everyone, I’m new in this page but I made three projects in Yii2, I have a doubt because my first two projects are working very good but the third have many rows and columns in my database and when I load any index.php it is very slow. Please anybody know how I can solve this problem? [/font][/size][/size][/size][/size][/size][/size][/size]
Find out exact reason for slowness using Debug toolbar and fix the root cause of it.
[size="3"][font="Arial"]Thank you for your answer. We have investigated and looked for information on the topic, we use the Yii Debugger to obtain more data. We believe that the problem is that when we load an index.php, in it we also show fields of other tables and for that reason it carries out so many queries to the database and the time of answer is bigger, but we are not sure that it is. I attach some images that can serve so that you help me to find the reason and to see how I can solve it, thousands of thank you.[font="Arial"][/font][/font][/size]
First of all, turn on schema caching. You have SHOW COLUMNS queries all over. Then, if your RBAC hierarchy isn’t changing often or is changed by, say, 10 admins only, try using PHP files to store it. Alternatively, turn on caching.
I don’t see the rest of the SQL queries but 243 are definitely too many.
The sql queries aren’t actually the problem - according to the pictures the sql time is several hundred milliseconds to maybe 1 second. But the overall page is taking 60+ seconds
That means you have some horribly inefficient php code somewhere (bad loops) or you have another external service that we don’t know about.
Edit: 243 queries is still a lot. Try to reduce that if you can but focus on finding the real cause first.
Edit2: I also remembered an issue I had when using GridView. If you show a lot of columns using ‘format’ => ‘html’, it may significantly affect performance. (It uses http://htmlpurifier.org/ which is very thorough but slow.)