CGridView rendered very slow


I am using CGridView to render a table. There would be a lot of "join" in SQL statement, because of complex model relations. It can be figured out in the following code:












	'filter'=>CHtml::listData(Partner::model()->findAll(), 'partnerID', 'partnerName'),



Now the CGridView table is rendered very slow, I think I need to set joint index in MySQL to speed up query.

If I know the SQL statement, then I can set joint index based on the fields used in "where" statement. Here is the problem: How can I know the exact SQL statement the CGridView used? Can the SQL statement be print out?

Thanks for your help

Yes you can see all output by using test webapp.


Check this extension:

Also make sure related objects are not lazy-loaded, you should use "with" or otherwise there will be really lots of queries in your case: