查看: 17767|回复: 11

使用exists、not eixsts不能用到semi-join、anti-join的一些情况讨论

[复制链接]
论坛徽章:
7
ITPUB元老
日期:2005-04-22 09:33:06授权会员
日期:2005-10-30 17:05:33铁扇公主
日期:2006-04-13 11:04:44紫蜘蛛
日期:2006-04-13 11:05:58会员2006贡献徽章
日期:2006-04-17 13:46:34BLOG每日发帖之星
日期:2009-05-24 01:01:022010新春纪念徽章
日期:2010-03-01 11:08:29
跳转到指定楼层
1#
发表于 2005-10-18 13:30 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
在Oralce中我们经常会使用exists、not exists来进行一些表连接操作,在普通情况下Oracle的
执行计划如果使用到semi-join、anti-join方式来进行表连接的话,速度一遍很快,否则很慢。通
过使用提示hash_sj hash_aj也可使执行计划走semi-join、anti-join。

但是在有些情况下,即使增加了提示,或者对表进行了分析后,执行计划也不走semi-join、anti-join
方式,下面就是对这些情况的讨论。

附注:本文中的例子均是在Oracle9.2.0.6 for linux中测试的。

1、在where条件中多个exists、not exists是or的关系

SQL> create table a1 as select * from dba_objects where rownum <= 10000;
SQL> create table a2 as
     select * from (select t.*,rownum rd from dba_objects t) p where rd>5000 and rd<= 15000;
SQL> create table a3 as
     select * from (select t.*,rownum rd from dba_objects t) p where rd>7500 and rd<= 17500;

SQL> analyze table a1 compute statistics;
SQL> analyze table a2 compute statistics;
SQL> analyze table a3 compute statistics;

SQL> set autotrace on exp
SQL> set timing on

----- exists or exists 情况

SQL> select a1.owner,count(*)
  2   from a1
  3  where exists
  4          (select /*+ hash_sj(a1 a2) */* from a2
  5            where a2.object_id=a1.object_id)
  6     or
  7        exists
  8          (select /*+ hash_sj(a1 a2) */* from a3
  9            where a3.object_id=a1.object_id)
10  group by a1.owner;

OWNER                            COUNT(*)
------------------------------ ----------
SYS                                  5000

已用时间: 00: 00: 26.66

Execution Plan
----------------------------------------------------------
   0      SELECT STATEMENT Optimizer=CHOOSE (Cost=18 Card=1 Bytes=7)
   1    0   SORT (GROUP BY) (Cost=18 Card=1 Bytes=7)
   2    1     FILTER
   3    2       TABLE ACCESS (FULL) OF 'A1' (Cost=17 Card=975 Bytes=6825)
   4    2       TABLE ACCESS (FULL) OF 'A2' (Cost=17 Card=1 Bytes=4)
   5    2       TABLE ACCESS (FULL) OF 'A3' (Cost=17 Card=1 Bytes=4)
   
   
执行计划中显然没有用到semi-jobin,这时候只有改写SQL,通过union all的方式来达到使用到
semi-join的目的。

SQL> select x.owner,count(*)
  2  from (select * from a1
  3          where exists
  4                (select /*+ hash_sj(a1 a2)*/* from a2
  5                  where a2.object_id= a1.object_id )
  6        union all
  7        select * from a1
  8          where not exists
  9                (select /*+ hash_aj(a1 p)*/* from a2 p
10                  where p.object_id=a1.object_id)
11            and exists
12                (select /*+ hash_sj(a1 a3)*/* from a3
13                  where a3.object_id=a1.object_id)
14        ) x
15  group by x.owner;

OWNER                            COUNT(*)
------------------------------ ----------
SYS                                  5000

已用时间:  00: 00: 00.31

Execution Plan
----------------------------------------------------------
   0      SELECT STATEMENT Optimizer=CHOOSE (Cost=90 Card=10001 Bytes=
          170017)

   1    0   SORT (GROUP BY) (Cost=90 Card=10001 Bytes=170017)
   2    1     VIEW (Cost=88 Card=10001 Bytes=170017)
   3    2       UNION-ALL
   4    3         HASH JOIN (SEMI) (Cost=35 Card=10000 Bytes=200000)
   5    4           TABLE ACCESS (FULL) OF 'A1' (Cost=17 Card=10000 Bytes=70000)

   6    4           VIEW OF 'VW_SQ_2' (Cost=17 Card=10000 Bytes=130000)

   7    6             TABLE ACCESS (FULL) OF 'A2' (Cost=17 Card=10000Bytes=40000)

   8    3         HASH JOIN (ANTI) (Cost=53 Card=1 Bytes=24)
   9    8           HASH JOIN (SEMI) (Cost=35 Card=10000 Bytes=200000)
  10    9             TABLE ACCESS (FULL) OF 'A1' (Cost=17 Card=10000 Bytes=70000)

  11    9             VIEW OF 'VW_SQ_1' (Cost=17 Card=10000 Bytes=130000)

  12   11               TABLE ACCESS (FULL) OF 'A3' (Cost=17 Card=10000 Bytes=40000)

  13    8           TABLE ACCESS (FULL) OF 'A2' (Cost=17 Card=10000 Bytes=40000)

----- not exists or not exists 情况

SQL> select a1.owner,count(*)
  2   from a1
  3  where not exists
  4          (select /*+ hash_sj(a1 a2) */* from a2
  5            where a2.object_id=a1.object_id)
  6     or
  7        not exists
  8          (select /*+ hash_sj(a1 a2) */* from a3
  9            where a3.object_id=a1.object_id)
10  group by a1.owner;

OWNER                            COUNT(*)
------------------------------ ----------
SYS                                  7500

已用时间:  00: 00: 20.72

Execution Plan
----------------------------------------------------------
   0      SELECT STATEMENT Optimizer=CHOOSE (Cost=18 Card=1 Bytes=7)
   1    0   SORT (GROUP BY) (Cost=18 Card=1 Bytes=7)
   2    1     FILTER
   3    2       TABLE ACCESS (FULL) OF 'A1' (Cost=17 Card=975 Bytes=6825)
   4    2       TABLE ACCESS (FULL) OF 'A2' (Cost=17 Card=1 Bytes=4)
   5    2       TABLE ACCESS (FULL) OF 'A3' (Cost=17 Card=1 Bytes=4)
   
SQL> select x.owner,count(*)
  2  from (select * from a1
  3          where not exists
  4                (select /*+ hash_sj(a1 a2)*/* from a2
  5                  where a2.object_id= a1.object_id )
  6        union all
  7        select * from a1
  8          where exists
  9                (select /*+ hash_aj(a1 p)*/* from a2 p
10                  where p.object_id=a1.object_id)
11            and not exists
12                (select /*+ hash_sj(a1 a3)*/* from a3
13                  where a3.object_id=a1.object_id)
14        ) x
15  group by x.owner;

OWNER                            COUNT(*)
------------------------------ ----------
SYS                                  7500

已用时间:  00: 00: 00.31

Execution Plan
----------------------------------------------------------
   0      SELECT STATEMENT Optimizer=CHOOSE (Cost=89 Card=2 Bytes=34)
   1    0   SORT (GROUP BY) (Cost=89 Card=2 Bytes=34)
   2    1     VIEW (Cost=88 Card=2 Bytes=34)
   3    2       UNION-ALL
   4    3         HASH JOIN (ANTI) (Cost=35 Card=1 Bytes=11)
   5    4           TABLE ACCESS (FULL) OF 'A1' (Cost=17 Card=10000 Bytes=70000)

   6    4           TABLE ACCESS (FULL) OF 'A2' (Cost=17 Card=10000 Bytes=40000)

   7    3         HASH JOIN (SEMI) (Cost=53 Card=1 Bytes=24)
   8    7           HASH JOIN (ANTI) (Cost=35 Card=1 Bytes=11)
   9    8             TABLE ACCESS (FULL) OF 'A1' (Cost=17 Card=10000 Bytes=70000)

  10    8             TABLE ACCESS (FULL) OF 'A3' (Cost=17 Card=10000 Bytes=40000)

  11    7           VIEW OF 'VW_SQ_1' (Cost=17 Card=10000 Bytes=130000)

  12   11             TABLE ACCESS (FULL) OF 'A2' (Cost=17 Card=10000 Bytes=40000)   


----- not exists or exists 情况

SQL> select a1.owner,count(*)
  2   from a1
  3  where  not exists
  4          (select /*+ hash_sj(a1 a2) */* from a2
  5            where a2.object_id=a1.object_id)
  6     or  exists
  7          (select /*+ hash_sj(a1 a3) */* from a3
  8            where a3.object_id=a1.object_id)
  9  group by a1.owner;

OWNER                            COUNT(*)
------------------------------ ----------
SYS                                  7500

已用时间:  00: 00: 20.57

Execution Plan
----------------------------------------------------------
   0      SELECT STATEMENT Optimizer=CHOOSE (Cost=18 Card=1 Bytes=7)
   1    0   SORT (GROUP BY) (Cost=18 Card=1 Bytes=7)
   2    1     FILTER
   3    2       TABLE ACCESS (FULL) OF 'A1' (Cost=17 Card=975 Bytes=6825)
   4    2       TABLE ACCESS (FULL) OF 'A2' (Cost=17 Card=1 Bytes=4)
   5    2       TABLE ACCESS (FULL) OF 'A3' (Cost=17 Card=1 Bytes=4)

SQL> select x.owner,count(*)
  2  from (select * from a1
  3          where not exists
  4                (select /*+ hash_sj(a1 a2)*/* from a2
  5                  where a2.object_id= a1.object_id )
  6        union all
  7        select * from a1
  8          where exists
  9                (select /*+ hash_aj(a1 p)*/* from a2 p
10                  where p.object_id=a1.object_id)
11            and exists
12                (select /*+ hash_sj(a1 a3)*/* from a3
13                  where a3.object_id=a1.object_id)
14        ) x
15  group by x.owner;

OWNER                            COUNT(*)
------------------------------ ----------
SYS                                  7500

已用时间:  00: 00: 00.32

Execution Plan
----------------------------------------------------------
   0      SELECT STATEMENT Optimizer=CHOOSE (Cost=90 Card=10001 Bytes=
          170017)

   1    0   SORT (GROUP BY) (Cost=90 Card=10001 Bytes=170017)
   2    1     VIEW (Cost=88 Card=10001 Bytes=170017)
   3    2       UNION-ALL
   4    3         HASH JOIN (ANTI) (Cost=35 Card=1 Bytes=11)
   5    4           TABLE ACCESS (FULL) OF 'A1' (Cost=17 Card=10000 Bytes=70000)

   6    4           TABLE ACCESS (FULL) OF 'A2' (Cost=17 Card=10000 Bytes=40000)

   7    3         HASH JOIN (SEMI) (Cost=53 Card=10000 Bytes=330000)
   8    7           HASH JOIN (SEMI) (Cost=35 Card=10000 Bytes=200000)
   9    8             TABLE ACCESS (FULL) OF 'A1' (Cost=17 Card=10000 Bytes=70000)

  10    8             VIEW OF 'VW_SQ_2' (Cost=17 Card=10000 Bytes=130000)

  11   10               TABLE ACCESS (FULL) OF 'A3' (Cost=17 Card=10000 Bytes=40000)

  12    7           VIEW OF 'VW_SQ_1' (Cost=17 Card=10000 Bytes=130000)

  13   12             TABLE ACCESS (FULL) OF 'A2' (Cost=17 Card=10000 Bytes=40000)
         

从上面的例子可以看出速度的提高是非常明显的,当然对于or的情况越多,修改后的SQL也就越复杂,不过相对于效率
的提高来说还是很值得的。



2、如果子句中含有group by这种排序操作,使用in来代替exists操作会大大提高效率,示例如下:

修改一下示例表:

SQL> insert into a2 select * from a2;
SQL> commit;

<1> 使用exists操作,无论添加什么提示都不能使其走semi-join,耗费大量时间

SQL> select count(*) from a1 a
  2   where exists
  3         ( select /*+ hash_sj(a b) */*
  4             from ( select object_id from a2
  5                   group by object_id having count(*) > 1
  6                   ) b
  7            where a.object_id=b.object_id
  8          );

  COUNT(*)
----------
      5000

已用时间:  00: 00: 46.22

Execution Plan
----------------------------------------------------------
   0      SELECT STATEMENT Optimizer=CHOOSE (Cost=34 Card=1 Bytes=4)
   1    0   SORT (AGGREGATE)
   2    1     FILTER
   3    2       TABLE ACCESS (FULL) OF 'A1' (Cost=17 Card=500 Bytes=2000)
   4    2       FILTER
   5    4         SORT (GROUP BY NOSORT) (Cost=17 Card=1 Bytes=4)
   6    5           TABLE ACCESS (FULL) OF 'A2' (Cost=17 Card=1 Bytes=4)
         
<2> 将exists改为in句型,就可以用到semi-join,效率大大提高

SQL> select count(*) from a1 a where object_id in
  2  ( select object_id  from a2 b
  3    group by  object_id having count(*) > 1
  4  );

  COUNT(*)
----------
      5000

已用时间:  00: 00: 00.90

Execution Plan
----------------------------------------------------------
   0      SELECT STATEMENT Optimizer=CHOOSE (Cost=37 Card=1 Bytes=17)
   1    0   SORT (AGGREGATE)
   2    1     HASH JOIN (SEMI) (Cost=37 Card=500 Bytes=8500)
   3    2       TABLE ACCESS (FULL) OF 'A1' (Cost=17 Card=10000 Bytes=40000)
   4    2       VIEW OF 'VW_NSO_1' (Cost=19 Card=500 Bytes=6500)
   5    4         FILTER
   6    5           SORT (GROUP BY) (Cost=19 Card=500 Bytes=2000)
   7    6             TABLE ACCESS (FULL) OF 'A2' (Cost=17 Card=10000 Bytes=40000)

对于not exists情况也是同样的,需要将语句改写为not in,但是要加上提示以及关联的列要有非空的限制
才能使其走anti-join的执行计划。

SQL> select count(*) from a1 a
  2   where not exists
  3         ( select /*+ hash_aj(a b)*/* from
  4                    ( select object_id from a2
  5                      group by object_id having count(*) > 1
  6                    ) b
  7            where a.object_id=b.object_id
  8          );

  COUNT(*)
----------
      5000

已用时间:  00: 00: 46.47

Execution Plan
----------------------------------------------------------
   0      SELECT STATEMENT Optimizer=CHOOSE (Cost=34 Card=1 Bytes=4)
   1    0   SORT (AGGREGATE)
   2    1     FILTER
   3    2       TABLE ACCESS (FULL) OF 'A1' (Cost=17 Card=500 Bytes=2000)

   4    2       FILTER
   5    4         SORT (GROUP BY NOSORT) (Cost=17 Card=1 Bytes=4)
   6    5           TABLE ACCESS (FULL) OF 'A2' (Cost=17 Card=1 Bytes=4)
   
SQL> select count(*) from a1 a
  2   where object_id is not null
  3     and object_id not in
  4          ( select object_id  from a2 b
  5             where object_id is not null
  6            group by  object_id having count(*) > 1
  7          );

  COUNT(*)
----------
      5000

已用时间:  00: 00: 00.75

Execution Plan
----------------------------------------------------------
   0      SELECT STATEMENT Optimizer=CHOOSE (Cost=37 Card=1 Bytes=17)
   1    0   SORT (AGGREGATE)
   2    1     HASH JOIN (ANTI) (Cost=37 Card=9500 Bytes=161500)
   3    2       TABLE ACCESS (FULL) OF 'A1' (Cost=17 Card=10000 Bytes=40000)
   4    2       VIEW OF 'VW_NSO_1' (Cost=19 Card=500 Bytes=6500)
   5    4         FILTER
   6    5           SORT (GROUP BY) (Cost=19 Card=500 Bytes=2000)
   7    6             TABLE ACCESS (FULL) OF 'A2' (Cost=17 Card=10000 Bytes=40000)
论坛徽章:
2
授权会员
日期:2005-10-30 17:05:33会员2006贡献徽章
日期:2006-04-17 13:46:34
2#
发表于 2005-10-18 19:32 | 只看该作者
不错的文章。。收藏

使用道具 举报

回复
论坛徽章:
14
会员2007贡献徽章
日期:2007-09-26 18:42:10生肖徽章2007版:鸡
日期:2009-10-29 16:15:30生肖徽章2007版:兔
日期:2009-04-14 19:32:34生肖徽章2007版:猴
日期:2008-11-28 10:39:32奥运会纪念徽章:摔跤
日期:2008-08-12 10:59:32奥运会纪念徽章:艺术体操
日期:2008-08-07 09:43:42奥运会纪念徽章:举重
日期:2008-05-04 17:12:35生肖徽章2007版:鼠
日期:2008-01-02 17:35:53生肖徽章2007版:牛
日期:2008-01-02 17:35:53生肖徽章2007版:虎
日期:2008-01-02 17:35:53
3#
发表于 2007-8-2 10:09 | 只看该作者
收藏了先。。。

使用道具 举报

回复
招聘 : Java研发
论坛徽章:
71
马上加薪
日期:2014-02-19 11:55:14蜘蛛蛋
日期:2012-12-26 18:16:01茶鸡蛋
日期:2012-11-16 08:12:48ITPUB 11周年纪念徽章
日期:2012-10-09 18:05:07奥运会纪念徽章:网球
日期:2012-08-23 14:58:08奥运会纪念徽章:沙滩排球
日期:2012-07-19 17:28:14版主2段
日期:2012-07-07 02:21:02咸鸭蛋
日期:2012-03-23 18:17:482012新春纪念徽章
日期:2012-02-13 15:13:512012新春纪念徽章
日期:2012-02-13 15:13:51
4#
发表于 2007-8-2 10:41 | 只看该作者
建议对a1、a2、a3的object_id字段建立索引再测。。。。

使用道具 举报

回复
招聘 : Java研发
论坛徽章:
71
马上加薪
日期:2014-02-19 11:55:14蜘蛛蛋
日期:2012-12-26 18:16:01茶鸡蛋
日期:2012-11-16 08:12:48ITPUB 11周年纪念徽章
日期:2012-10-09 18:05:07奥运会纪念徽章:网球
日期:2012-08-23 14:58:08奥运会纪念徽章:沙滩排球
日期:2012-07-19 17:28:14版主2段
日期:2012-07-07 02:21:02咸鸭蛋
日期:2012-03-23 18:17:482012新春纪念徽章
日期:2012-02-13 15:13:512012新春纪念徽章
日期:2012-02-13 15:13:51
5#
发表于 2007-8-2 10:46 | 只看该作者
我帮你试了下,呵呵
[php]
create index i_index_a1 on a1 (object_id)
create index i_index_1 on a2 (object_id)
create index i_index_2 on a3 (object_id)

SQL>  select x.owner,count(*)
  2   from (select * from a1
  3   where exists
  4   (select /*+ hash_sj(a1 a2)*/* from a2
  5   where a2.object_id= a1.object_id )
  6   union all
  7   select * from a1
  8   where not exists
  9   (select /*+ hash_aj(a1 p)*/* from a2 p
10   where p.object_id=a1.object_id)
11   and exists
12   (select /*+ hash_sj(a1 a3)*/* from a3
13   where a3.object_id=a1.object_id)
14   ) x
15   group by x.owner;

已选择13行。

已用时间:  00: 00: 00.07

Execution Plan
----------------------------------------------------------
   0      SELECT STATEMENT Optimizer=CHOOSE (Cost=52 Card=525 Bytes=89
          25)

   1    0   SORT (GROUP BY) (Cost=52 Card=525 Bytes=8925)
   2    1     VIEW (Cost=1152 Card=525 Bytes=8925)
   3    2       UNION-ALL
   4    3         FILTER
   5    4           TABLE ACCESS (FULL) OF 'A1' (Cost=26 Card=500 Byte
          s=4500)

   6    4           INDEX (RANGE SCAN) OF 'I_INDEX_1' (NON-UNIQUE) (Co
          st=2 Card=1 Bytes=5)

   7    3         FILTER
   8    7           TABLE ACCESS (FULL) OF 'A1' (Cost=26 Card=25 Bytes
          =225)

   9    7           INDEX (RANGE SCAN) OF 'I_INDEX_1' (NON-UNIQUE) (Co
          st=2 Card=1 Bytes=5)

  10    7           INDEX (RANGE SCAN) OF 'I_INDEX_2' (NON-UNIQUE) (Co
          st=2 Card=1 Bytes=5)





Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
      50260  consistent gets
          0  physical reads
          0  redo size
        542  bytes sent via SQL*Net to client
        495  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          1  sorts (memory)
          0  sorts (disk)
         13  rows processed

SQL> select a1.owner, count(*)
  2    from a1
  3   where exists (select 1
  4            from a2
  5           where a2.object_id = a1.object_id) or exists
  6   (select 1
  7            from a3
  8           where a3.object_id = a1.object_id)
  9   group by a1.owner;

已选择13行。

已用时间:  00: 00: 00.07

Execution Plan
----------------------------------------------------------
   0      SELECT STATEMENT Optimizer=CHOOSE (Cost=27 Card=13 Bytes=117
          )

   1    0   SORT (GROUP BY) (Cost=27 Card=13 Bytes=117)
   2    1     FILTER
   3    2       TABLE ACCESS (FULL) OF 'A1' (Cost=26 Card=975 Bytes=87
          75)

   4    2       INDEX (RANGE SCAN) OF 'I_INDEX_1' (NON-UNIQUE) (Cost=2
           Card=1 Bytes=5)

   5    2       INDEX (RANGE SCAN) OF 'I_INDEX_2' (NON-UNIQUE) (Cost=2
           Card=1 Bytes=5)





Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
      30130  consistent gets
          0  physical reads
          0  redo size
        542  bytes sent via SQL*Net to client
        495  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          1  sorts (memory)
          0  sorts (disk)
         13  rows processed---
[/php]

使用道具 举报

回复
论坛徽章:
0
6#
发表于 2008-4-28 09:22 | 只看该作者
好文章

使用道具 举报

回复
论坛徽章:
273
生肖徽章2007版:猪
日期:2008-09-27 09:35:45明尼苏达森林狼
日期:2009-01-12 14:15:09生肖徽章2007版:猪
日期:2009-01-21 16:30:59布鲁克林篮网
日期:2009-03-03 14:42:32圣安东尼奥马刺
日期:2009-03-03 14:44:41生肖徽章2007版:鸡
日期:2009-03-03 21:45:52生肖徽章2007版:牛
日期:2009-03-09 14:03:42生肖徽章2007版:猪
日期:2009-03-10 21:37:00生肖徽章2007版:羊
日期:2009-03-16 10:17:11生肖徽章2007版:虎
日期:2009-03-24 21:26:52
7#
发表于 2008-5-3 15:13 | 只看该作者
不错
谢谢分享

使用道具 举报

回复
论坛徽章:
0
8#
发表于 2008-6-11 11:35 | 只看该作者
好,学习下

使用道具 举报

回复
论坛徽章:
50
2014年世界杯参赛球队: 荷兰
日期:2014-07-11 07:56:59蛋疼蛋
日期:2012-03-06 07:22:542012新春纪念徽章
日期:2012-02-13 15:09:522012新春纪念徽章
日期:2012-02-13 15:09:522012新春纪念徽章
日期:2012-02-13 15:09:522012新春纪念徽章
日期:2012-02-13 15:09:522012新春纪念徽章
日期:2012-02-13 15:09:522012新春纪念徽章
日期:2012-01-04 11:53:29蛋疼蛋
日期:2011-11-11 15:47:00ITPUB十周年纪念徽章
日期:2011-11-01 16:23:26
9#
发表于 2009-3-17 17:01 | 只看该作者
要改写的那么累吗?足够的分析ORACLE不会选择ANTI JOIN之类的吗,还要加HINT,改写脚本,有点想不明白

使用道具 举报

回复
招聘 : Java研发
论坛徽章:
71
马上加薪
日期:2014-02-19 11:55:14蜘蛛蛋
日期:2012-12-26 18:16:01茶鸡蛋
日期:2012-11-16 08:12:48ITPUB 11周年纪念徽章
日期:2012-10-09 18:05:07奥运会纪念徽章:网球
日期:2012-08-23 14:58:08奥运会纪念徽章:沙滩排球
日期:2012-07-19 17:28:14版主2段
日期:2012-07-07 02:21:02咸鸭蛋
日期:2012-03-23 18:17:482012新春纪念徽章
日期:2012-02-13 15:13:512012新春纪念徽章
日期:2012-02-13 15:13:51
10#
发表于 2009-3-17 20:13 | 只看该作者
原帖由 wabjtam123 于 2009-3-17 17:01 发表
要改写的那么累吗?足够的分析ORACLE不会选择ANTI JOIN之类的吗,还要加HINT,改写脚本,有点想不明白

现在看来楼主的分析很有道理,CBO也确实是存在一些RULE的,在某些RULE下足够的分析也是不够的

[ 本帖最后由 anlinew 于 2009-3-17 20:14 编辑 ]

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表