CGridView rendered very slow

Hi,

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:


array(

	'header'=>'Plan',

	'name'=>'plan_search',

	'value'=>'$data->domain->plan->planName',

	'htmlOptions'=>array('width'=>'15%'),

),

array(

	'header'=>'Partner',

	'name'=>'partner_search',

	'type'=>'html',

	'value'=>'$data->domain->account->partner->partnerName',

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

	'htmlOptions'=>array('width'=>'12%'),

),

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.

Use http://yourhost.com/index-test.php

Check this extension: http://www.yiiframework.com/extension/yii-debug-toolbar/

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: http://www.yiiframework.com/doc/guide/1.1/en/database.arr#performing-relational-query