ITPUB??ì3
12月微软Hyper-V虚拟化沙龙主题征集
ITPUB论坛 » Oracle开发 » 这个sql为什么用地卡尔积?

标题: 这个sql为什么用地卡尔积?
离线 dblife
uttermost


精华贴数 2
个人空间 0
技术积分 1388 (1248)
社区积分 647 (1240)
注册日期 2001-10-10
论坛徽章:4
ITPUB元老会员2006贡献徽章授权会员生肖徽章2007版:鼠  
      

发表于 2002-4-1 21:37 
这个sql为什么用地卡尔积?

select B.AREACODE as domain,D.ITEMTYPECODE,sum(A.SALEAMT) saleAmt
from serp01.mag_customer_sale_state_type A,
     serp01.pub_area_code B,
     serp01.pub_area_code_explode C,
    serp01.pub_item_type_code D,
     serp01.pub_item_type_explode E
where
     a.enterprisecode = e.enterprisecode
and a.enterprisecode = d.enterprisecode
and a.enterprisecode = c.enterprisecode
and a.enterprisecode = b.enterprisecode
and A.EnterpriseCode = 'sygs'

and a.ITEMTYPECODE = e.ChildItemTypeCode  
and e.parentitemtypecode = d.itemtypecode
and d.parentitemtypecode is null
and a.areacode = c.childareacode
and c.parentareacode = b.areacode
and b.parentareacode is null
and A.SALEDATE >= '2002/01/01'
明明5个表有4个连接条件,但是仍然有cartersian奇怪
group by B.AREACODE, D.ITEMTYPECODE



SELECT STATEMENT, GOAL = CHOOSE                        1385        1        150       
SORT GROUP BY                        1385        1        150       
  NESTED LOOPS                        1371        1        150       
   NESTED LOOPS                        1371        50        6700       
    MERGE JOIN CARTESIAN                        1371        993        122139       
     MERGE JOIN CARTESIAN                        6        1        49       
      TABLE ACCESS FULL        SERP01        PUB_AREA_CODE        5        1        28       
      SORT JOIN                        1        1        21       
       INDEX RANGE SCAN        SERP01        PUB_ITEM_TYPE_CODE_IDX_004        2        1        21       
     SORT JOIN                        1370        993        73482       
      TABLE ACCESS FULL        SERP01        MAG_CUSTOMER_SALE_STATE_TYPE        1365        993        73482       
    INDEX UNIQUE SCAN        SERP01        PK47                3        33       
   INDEX UNIQUE SCAN        SERP01        PK326                39        624       



只看该作者    顶部
离线 Arrayjlandzpa
版主


精华贴数 29
个人空间 0
技术积分 45963 (15)
社区积分 53595 (10)
注册日期 2001-10-12
论坛徽章:16
现任管理团队成员ITPUB元老授权会员生肖徽章2007版:牛ITPUB新首页上线纪念徽章 
      

发表于 2002-4-1 23:49 
呵呵

What is Star Query Optimization ?
You'll probably see an execution plan like this
Merge Join Cartesian

fullscan A
fullscan B
This is an effect of the Star Query Optimization. Star Query states that if table A and B are small, then it's more efficient to do a direct Cartesian Product (i.e. try all the combinaisons) than to do a regular Join. It's very efficient when the tables are actually small. The time to query such a join is proportional to NumberOfLine(Table A) * NumberOfLine(Table B). The only problem is that Oracle considers a table as small if it fits in the SGA. If you have a big SGA (let's say 500 MO) then any couple of table smaller than 500 MO is candidate to such query optimisation. Actually in alot of cases, you don't want such Star Query.


__________________
my blog: http://blog.itpub.net/jlandzpa
mail: “id”@itpub.net

注意: [投资理财版] 业已提供上证指数菠菜,欢迎参与 :)

[头像] 黑木明纱 Meisa Kuroki  :)
只看该作者    顶部
离线 dblife
uttermost


精华贴数 2
个人空间 0
技术积分 1388 (1248)
社区积分 647 (1240)
注册日期 2001-10-10
论坛徽章:4
ITPUB元老会员2006贡献徽章授权会员生肖徽章2007版:鼠  
      

发表于 2002-4-2 10:27 
这个问题的原因已经找到了

是主键的索引次序不对,我现在太忙,等完了,可以好好写一下


只看该作者    顶部
在线/呼叫 biti_rainy
人生就是如此



精华贴数 38
个人空间 0
技术积分 111199 (4)
社区积分 11832 (132)
注册日期 2001-12-12
论坛徽章:41
现任管理团队成员ITPUB长老会成员ITPUB元老年度论坛发贴之星年度论坛发贴之星ITPUB北京九华山庄2008年会纪念徽章
管理团队2007贡献徽章参与2007年甲骨文全球大会(中国上海)纪念ITPUB北京香山2007年会纪念徽章管理团队2006纪念徽章会员2007贡献徽章会员2006贡献徽章

发表于 2002-4-2 16:20 
faint

老哥你也忒不小心了


__________________
眼界决定边界,态度决定高度
blog:
人生就是如此
只看该作者    顶部
 
    

相关内容


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