- 最后登录
- 2015-5-21
- 在线时间
- 100 小时
- 威望
- 0
- 金钱
- 345
- 注册时间
- 2012-12-19
- 阅读权限
- 10
- 帖子
- 99
- 精华
- 0
- 积分
- 0
- UID
- 824
|
1#
发表于 2013-1-31 10:13:20
|
查看: 4167 |
回复: 5
做了个小实验在测试库上10g,olap数据库,有两张表mmt,mtln数据量都在100万行左右,其中都有一列organization_id列,其中mmt中- SQL> select organization_id from mtl_material_transactions group by organization_id;
-
- ORGANIZATION_ID
- ---------------
- 105
- 106
- 107
- 137
-
复制代码 mtln中- SQL> select organization_id from mtl_transaction_lot_numbers group by organization_id;
-
- ORGANIZATION_ID
- ---------------
- 106
- 107
-
复制代码 有一个查询- select mmt.organization_id,
- mmt.subinventory_code,
- nvl(mtln.transaction_quantity, mmt.primary_quantity) transaction_quantity,
- mmt.TRANSACTION_ACTION_ID,
- mmt.INVENTORY_ITEM_ID,
- mmt.transaction_type_id,
- mtln.lot_number,
- mmt.transaction_id
- from mtl_material_transactions mmt, mtl_transaction_lot_numbers mtln
- where mmt.transaction_id = mtln.transaction_id(+)
- and mmt.organization_id = mtln.organization_id(+)
- and mmt.organization_id = 106
复制代码 我在organization_id 列上添加了位图索引,transaction_id 和organization_id 上添加了符合索引,为什么执行计划依然走的全表扫面(全外连接会影响但是我加了条organization_id = 106想去限制它,让执行计划自行去找索引)为什么没有走索引呢?
注:没添加索引前大约查询20多秒,添加索引后执行计划没变但是变成7秒了,测试库没其他操作影响,这又是为什么?
- 1
- 2 --------------------------------------------------------------------------------------------------
- 3 | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)|
- 4 --------------------------------------------------------------------------------------------------
- 5 | 0 | SELECT STATEMENT | | 983K| 73M| | 71889 (1)|
- 6 |* 1 | HASH JOIN RIGHT OUTER| | 983K| 73M| 25M| 71889 (1)|
- 7 |* 2 | TABLE ACCESS FULL | MTL_TRANSACTION_LOT_NUMBERS | 594K| 18M| | 10365 (2)|
- 8 |* 3 | TABLE ACCESS FULL | MTL_MATERIAL_TRANSACTIONS | 983K| 42M| | 57580 (1)|
- 9 --------------------------------------------------------------------------------------------------
- 10
- 11 Predicate Information (identified by operation id):
- 12 ---------------------------------------------------
- 13
- 14 1 - access("MMT"."TRANSACTION_ID"="MTLN"."TRANSACTION_ID"(+) AND
- 15 "MMT"."ORGANIZATION_ID"="MTLN"."ORGANIZATION_ID"(+))
- 16 2 - filter("MTLN"."ORGANIZATION_ID"(+)=106)
- 17 3 - filter("MMT"."ORGANIZATION_ID"=106)
- 18
复制代码 |
|