1 sql优化 - IBM数据库产品 - ITPUB论坛 - IT168旗下专业技术社区

ITPUB??ì3
众志成城 抗震救灾_IXPUB.NET技术社区专题

标题: sql优化
离线 tanfufa
资深会员



精华贴数 0
个人空间 0
技术积分 3211 (413)
社区积分 11 (9489)
注册日期 2005-9-27
论坛徽章:3
会员2007贡献徽章生肖徽章2007版:鸡ITPUB新首页上线纪念徽章   
      

发表于 2007-7-16 11:41 
sql优化

406/350
select * from (
select rownumber() over() as rownumber_, row_.*
from (
select distinct alias_sp_cms_info.c_node_id as id, alias_file.c_type_id as type,                 

alias_sp_cms_info.c_prop_top_level_s as top_level, alias_sp_cms_info.c_prop_order_num_s as order_num
from t_file_permission_split alias_fp, t_file_cms_info_s alias_sp_cms_info, t_file  alias_file
where (
     (
     (
     (
     (
     (
     (
     (
       (alias_sp_cms_info.c_path like ?)
and (alias_sp_cms_info.c_prop_validate_time_s <= ?)
     )
and  (
    (alias_sp_cms_info.c_prop_invalidate_time_s is null)
or (alias_sp_cms_info.c_prop_invalidate_time_s > ?)
      )
        )
and (alias_sp_cms_info.c_prop_character_s <> ?)
   )  
and ((alias_file.c_status = ?)
or (alias_file.c_status = ?))
   )
and ((alias_sp_cms_info.c_prop_info_test_s is null)
or (alias_sp_cms_info.c_prop_info_test_s = ?))
   )
and (alias_sp_cms_info.c_prop_character_s = alias_sp_cms_info.c_prop_character_s)
   )
and (alias_sp_cms_info.c_node_id = alias_file.c_id)
   )
and
   (
    (alias_sp_cms_info.c_node_id = alias_fp.c_file_id)
and exists
   (select c_permission_id from t_permission_set where c_permission_id = alias_fp.C_PERMISSION_ID and c_allow_type=0 and

((c_owner_type = 'user' and c_owner_id = 2)
or (c_owner_type = 'group' and c_owner_id in (937, 938))))
and not exists (select c_permission_id from t_permission_set where c_permission_id = alias_fp.C_PERMISSION_ID and

c_allow_type=1 and alias_fp.C_PERMISSION_TYPE = 1 and ((c_owner_type = 'user' and c_owner_id = 2) or (c_owner_type = 'group'

and c_owner_id in (937, 938)))))) order by alias_sp_cms_info.c_prop_top_level_s desc, alias_sp_cms_info.c_prop_order_num_s

desc ) as row_ ) as temp_ where rownumber_ <= ?

不知道这条语句与什么优化的空间没有


顶部
离线 whoandwho
IBM软件技术精英协会成员



精华贴数 0
个人空间 0
技术积分 242 (7509)
社区积分 0 (1211673)
注册日期 2006-12-18
论坛徽章:1
IBM软件技术精英协会成员     
      

发表于 2007-7-16 11:51 
建议你把执行路径和索引情况分析分析
$ db2expln -d dbname -u db2inst1 password -t -g -f select.sql > explain.out


顶部
离线 tanfufa
资深会员



精华贴数 0
个人空间 0
技术积分 3211 (413)
社区积分 11 (9489)
注册日期 2005-9-27
论坛徽章:3
会员2007贡献徽章生肖徽章2007版:鸡ITPUB新首页上线纪念徽章   
      

发表于 2007-7-16 12:17 
谢谢.好的


顶部
在线/呼叫 askgyliu
老会员



精华贴数 0
个人空间 0
技术积分 1372 (1137)
社区积分 0 (1425368)
注册日期 2007-6-14
论坛徽章:4
现任管理团队成员会员2007贡献徽章ITPUB新首页上线纪念徽章在线时间  
      

发表于 2007-7-16 21:53 
复杂的东西建议分几步做。


顶部
离线 bpmfhu
风往北吹



精华贴数 11
个人空间 0
技术积分 8467 (134)
社区积分 990 (832)
注册日期 2001-12-26
论坛徽章:22
现任管理团队成员ITPUB元老itpub2007年荐股参与纪念徽章管理团队2007贡献徽章管理团队2006纪念徽章会员2007贡献徽章
会员2006贡献徽章授权会员2008年新春纪念徽章ITPUB新首页上线纪念徽章生肖徽章:猪生肖徽章:狗

发表于 2007-7-17 07:21 
分析执行计划db2expln
建立合适的索引db2advis
如果是存储过程,建议分开几步来做


__________________
茅屋之下,或有贤良;蒿草之中,或有兰香. Blog:http://www.free2way.net
顶部
离线 whwjj80
初级会员



精华贴数 0
个人空间 0
技术积分 18 (56475)
社区积分 0 (1354903)
注册日期 2007-4-27
论坛徽章:0
      
      

发表于 2007-7-17 11:35 
太复杂的,可使用存储过程.


顶部
离线 tanfufa
资深会员



精华贴数 0
个人空间 0
技术积分 3211 (413)
社区积分 11 (9489)
注册日期 2005-9-27
论坛徽章:3
会员2007贡献徽章生肖徽章2007版:鸡ITPUB新首页上线纪念徽章   
      

发表于 2007-7-17 13:03 
其实很简单的一句话.就是where 条件复杂点


顶部
 
    

相关内容


CopyRight 1999-2006 itpub.net All Right Reserved.
北京皓辰广域网络信息技术有限公司. 版权所有
E-mail:Webmaster@itpub.net
京ICP证:010037号 联系我们 法律顾问