永发信息网

为什么这两种Oracle查询语句,执行计划有这么大的差异?

答案:1  悬赏:60  手机版
解决时间 2021-08-17 13:03

select
       d.statis_date,
 d.area_code,
 d.cell_sale_id,
 count(c.serv_number)
  from (select distinct (case
           when(a.whole_fee > 0 or a.word_fee>0) then
                             a.msisdn
                            when(a.msisdn = b.msisdn and (a.book_chpt_cnt > 0 or a.book_download_cnt > 0)) then
       a.msisdn
                            else
                             null
                         end) serv_number
          from masadw.tb_dw_ns_read_user_act_list a,
               masadw.tb_dw_ns_read_user_order_list b
         where a.msisdn = b.msisdn(+)
           and a.deal_date between vd_first_date and vd_date
           and b.deal_date between vd_first_date and vd_date) c
        masadw.tb_mk_sc_user_dtal d
  where c.serv_number = d.serv_number
    and c.user_status_id <> 'H'
    and c.statis_date = vd_date
  group by d.statis_date,
     d.area_code,
     d.cell_sale_id;

执行计划:
                                                 对象                                 耗费
-select statement,goal=all rows
 -sort group by
  -view                                        VM_NWVW_1
   -sort unique          
    -filter
     -filter
      -hash join outer
       -merge join cartesian
        -partition list iterator
         table access all                 TB_DW_NS_READ_USER_ACT_LIST                  10030
        -buffer sort
         -partition range single
          -partition list all
           table access all               TB_MK_SC_USER_DTAL                           64756033
       -partition list iterator
        table access full                 TB_DW_NS_READ_USER_ORDER_LIST                94268


select
       b.statis_date,
 b.area_code,
 b.cell_sale_id,
 count(case
    when a.new_stdt_count = '1' then
                a.serv_number
               else
                null
             end)
  from masadw.tb_kr_campus_user_dtal a,
       masadw.tb_mk_sc_user_dtal b
  where a.serv_number = b.serv_number
    and b.user_status_id <> 'H'
    and a.statis_date = vd_date
    and b.statis_date = vd_date
  group by b.statis_date,
     b.area_code,
     b.cell_sale_id;

执行计划:
                                                 对象                                   耗费
-select statement,goal=all rows
 -PX COORDINATOR
  -PX SEND QC(RANDOW)                            :TQ10003                              98152
   -SORT GROUP BY
    -PX RECEIVE
     -PX SEND HASH                               :TQ10002                              98152
      -SORT GROUP BY
       -HASH JOIN
        -BUFFER SORT
         -PX RECEIVE
          -PX SEND HASH                          :TQ10000                              31066
           -PARTITION LIST SINGLE
            TABLE ACCESS FULL                    TB_KR_CAMPUS_USER_DTAL                31066
        -PX RECEIVE
         -PX SEND HASH                           :TQ10001                              67082
          -PX BLOCK ITERATOR
           TABLE ACCESS FULL                     TB_MK_SC_USER_DTAL                    67082

         

         

最佳答案
select b.* from(select rownum num, a.* from users a)bwhere b.num>=7 and b.num<=9
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
武艺和陈翔会一起合作吗
爱国标语经典用语大全,根据红阿斯杀虫剂案例
做假体隆鼻有哪些副作用呢?
RAW的新总经理到底是谁啊
有一首歌的歌词里是:我习惯你走在我的身后。
跟夏天有关的诗歌,夏天夜晚思念情人诗句
萨尔图区大庆美丽衣橱(毅腾商都购物中心店)在
初三了、要怎么复习
查话费清单发现手机无故发短信给陌生号码
岳阳原来属于三国哪个国家的?
小香蕉一根多少克,一根香蕉,一个苹果,一根
带有不的诗词,有关深秋的 遥思 诗句
谁能帮我飞车!真心的!没钱给你哟!要道50J
头发打蜡后有什么影响,头发打蜡后多久才能再
关于团结互助的格言,我们一群女队员参加拓展
推荐资讯
I`ll give the note to him as soon as_____.
穿越火线帮助成员“清清”来,(其它人靠边站
人的一生必须依靠的十种人
no power no live 是什么意思?
精武堂怎样刷矿
电影经典台词关于励志,英语励志经典语句
搜狗手机输入法1.4版有哪些自带皮肤?
1.绝对值最小的有理数是?,绝对值等于1的数是?
你有激浪饮料cf兑换码啊?
五十四级不能拜师了吗?
5230港行的是全国联保么?
八鄝穴在哪里,如何找到?
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?