| 发表于:2007-11-02 12:37:23 楼主 |
问大家一下多表查询优化的方法。。。。 如果一个查询语句。。select b.bf_branchno,u.user_masterid,u.user_opendate,c.cif_name,c.cif_telno,c.cif_email,sum(t.trs_amount) as totalamount,count(t.trs_amount) as totalcount from ibs_tab_bankframe b,ibs_tab_cif c,ibs_tab_user u left join ibs_tab_transfer t on u.user_loginid=t.trs_masterid where b.bf_unitno=c.cif_unitno and c.cif_masterid = u.user_loginid and c.cif_type='ciftype' group by b.bf_branchno,u.user_masterid,u.user_opendate,c.cif_name,c.cif_telno,c.cif_email order by b.bf_branchno,totalamount desc,totalcount desc 是不是在象b.bf_unitno=c.cif_unitno这种两表字段相等的变量建上索引就行?其他的c.cif_type='ciftype'象这种定值的需要建索引吗? 怎样会速度快些?谢谢各位了~~ |
|
|
|
|