Oracle数据库数据恢复、性能优化

找回密码
注册
搜索
热搜: 活动 交友 discuz
发新帖

0

积分

1

好友

29

主题
1#
发表于 2013-1-11 09:09:36 | 查看: 3201| 回复: 3
select * from v$version;
1        Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
2        PL/SQL Release 10.2.0.3.0 - Production
3        CORE        10.2.0.3.0        Production
4        TNS for IBM/AIX RISC System/6000: Version 10.2.0.3.0 - Productio
5        NLSRTL Version 10.2.0.3.0 - Production

原语句:
select mmt.organization_id, mmt.subinventory_code, mmt.attribute10,  mmt.transaction_date,nvl(mtln.transaction_quantity,mmt.primary_quantity) transaction_quantity
   from mtl_material_transactions   mmt, mtl_transaction_lot_numbers mtln
  where mmt.transaction_id = mtln.transaction_id(+)
  and mmt.organization_id = mtln.organization_id(+);
执行计划:
1         
2        --------------------------------------------------------------------------------------------------
3        | Id  | Operation             | Name                        | Rows  | Bytes |TempSpc| Cost (%CPU)|
4        --------------------------------------------------------------------------------------------------
5        |   0 | SELECT STATEMENT      |                             |  4779K|   355M|       | 99767   (2)|
6        |*  1 |  HASH JOIN RIGHT OUTER|                             |  4779K|   355M|    63M| 99767   (2)|
7        |   2 |   TABLE ACCESS FULL   | MTL_TRANSACTION_LOT_NUMBERS |  1470K|    46M|       | 12978   (3)|
8        |   3 |   TABLE ACCESS FULL   | MTL_MATERIAL_TRANSACTIONS   |  4779K|   205M|       | 70656   (2)|
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         
17        Note
18        -----
19           - 'PLAN_TABLE' is old version

如果语句中必须有类似mmt.transaction_id = mtln.transaction_id(+)这类语句能不能避免对表的全扫面?我想到的通过修改访问路径或者添加索引好像不能解决,有没有高手能指点一下
2#
发表于 2013-1-11 09:17:23
外连接本就是耗费性能的连接,  可否找到等从SQL。 如果不能, 试试让执行计划去NL连接呢,
select /*+ use_nl(mmt mtln) leading(mtln) index(mmt)*/ mmt.organization_id, mmt.subinventory_code, mmt.attribute10,  mmt.transaction_date,nvl(mtln.transaction_quantity,mmt.primary_quantity) transaction_quantity
   from mtl_material_transactions   mmt, mtl_transaction_lot_numbers mtln
  where mmt.transaction_id = mtln.transaction_id(+)
  and mmt.organization_id = mtln.organization_id(+);

试试看有没有改变?

回复 只看该作者 道具 举报

3#
发表于 2013-1-11 09:18:39
where mmt.transaction_id = mtln.transaction_id(+)
  and mmt.organization_id = mtln.organization_id(+);

where 条件内除了2表 关联之外 没有任何 其他可用谓词, 使用 全表+HASH JOIN是很合适的执行计划。

这个SQL最多能做的是 把2个TABLE FULL SCAN 转成 2个INDEX FAST FULL SCAN

回复 只看该作者 道具 举报

4#
发表于 2013-1-11 10:39:24
Maclean Liu(刘相兵 发表于 2013-1-11 09:18
where mmt.transaction_id = mtln.transaction_id(+)
  and mmt.organization_id = mtln.organization_id(+ ...

懂了,就是想了解下类似的有什么好方法,感谢刘大

回复 只看该作者 道具 举报

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

QQ|手机版|Archiver|Oracle数据库数据恢复、性能优化

GMT+8, 2024-6-15 08:34 , Processed in 0.047937 second(s), 20 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部
TEL/電話+86 13764045638
Email service@parnassusdata.com
QQ 47079569