您的位置:程序门 -> db2 -> 基础类



急问各位!!关于多表连查的优化~~效率问题~~怎样select速度会快些?谢谢各位啦~~~


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


急问各位!!关于多表连查的优化~~效率问题~~怎样select速度会快些?谢谢各位啦~~~
发表于: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'象这种定值的需要建索引吗?

怎样会速度快些?谢谢各位了~~
发表于:2007-11-02 14:06:461楼 得分:0
察看执行计划,网上很多这样的帖子,是否加索引,还需要看你的数据。
发表于:2007-11-02 15:47:252楼 得分:0
你使用explain看一下.
在db2的控制中心里就用.执行这个sql的时候.会给你执行计划.里面会告诉你优化方式.


快速检索

最新资讯
热门点击