Does this seem like a heck of alot of queries to be running?

On the list page of my website ( ) - It says its running 140 queries, does this seem like alot?

What would you recommend to reduce?


Using active record means that you get ‘N’ queries - however many objects (rows) you are returning.

See which code is pulling the most queries and use the ‘with’ operator to bring all the data back in 1 query, or write custom SQL to do the same.

140 is quite alot, its worth looking at the queries and use optimised versions instead if your not happy with what Yii generates.

Maybe you can reduce using ‘with’ in the dataprovider

The number is a lot on a per request basis so as some of the suggestion above, eager load the associations by using the ‘with’ parameter in the query or look at where you are possibly duplicating queries using the profiler. Once all that is done and you are satisfied that every sql is required and is as efficient as can be, start to introduce caching for some queries to save performance on your database. Good caching will make your site appear super fast, but you need to be smart where you use it.

140 queries is a lot, But I am surprised that the page loads fast. Mine has 50ish queries and it loads slower than your. I hope it will be faster when it lives on production server + tuning tricks. Anyway, read - it talks about caching queries which reduces your subsequent query calls.