oracle10gR2 中, 用 in 还是 用or的问题

select table_name from test where table_name='DBMS_ALERT_INFO' or  table_name ='DBMS_APPS_UPG_WORKING';

执行计划
----------------------------------------------------------
Plan hash value: 2019477598

-------------------------------------------------------------------------------------
| Id  | Operation         | Name            | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |                 |    12 |   204 |     3   (0)| 00:00:01 |
|   1 |  INLIST ITERATOR  |                 |       |       |            |          |
|*  2 |   INDEX RANGE SCAN| IDX_TEST_TBNAME |    12 |   204 |     3   (0)| 00:00:01 |
-------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - access("TABLE_NAME"='DBMS_ALERT_INFO' OR
              "TABLE_NAME"='DBMS_APPS_UPG_WORKING')

Note
-----
   - dynamic sampling used for this statement


统计信息
----------------------------------------------------------
          5  recursive calls
          0  db block gets
         81  consistent gets
          0  physical reads
          0  redo size
        546  bytes sent via SQL*Net to client
        385  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
         14  rows processed

 

 

select table_name from test where table_name in ('DBMS_ALERT_INFO','DBMS_APPS_UPG_WORKING');

执行计划
----------------------------------------------------------
Plan hash value: 2019477598

-------------------------------------------------------------------------------------
| Id  | Operation         | Name            | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |                 |    12 |   204 |     3   (0)| 00:00:01 |
|   1 |  INLIST ITERATOR  |                 |       |       |            |          |
|*  2 |   INDEX RANGE SCAN| IDX_TEST_TBNAME |    12 |   204 |     3   (0)| 00:00:01 |
-------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - access("TABLE_NAME"='DBMS_ALERT_INFO' OR
              "TABLE_NAME"='DBMS_APPS_UPG_WORKING')

Note
-----
   - dynamic sampling used for this statement


统计信息
----------------------------------------------------------
          4  recursive calls
          0  db block gets
         81  consistent gets
          0  physical reads
          0  redo size
        546  bytes sent via SQL*Net to client
        385  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
         14  rows processed

 

 

结论:

(1)都会使用索引。

(2)用 in 少一个递归调用!

 

记得以后尽量用in!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值