|
原帖由 anlinew 于 2008-4-15 15:47 发表 ![]()
你的是RBO,DK讲的那句RBO下应该没问题
确实是这样,我换成CBO,就不产生临时段了
SQL> analyze table o compute statistics;
表已分析。
SQL> analyze table o2 compute statistics;
表已分析。
SQL> explain plan for select * from o where o.object_id in (select object_id fr
om o2) and rownum<20;
已解释。
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost |
----------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 19 | 6863K| | 1241 |
|* 1 | COUNT STOPKEY | | | | | |
|* 2 | HASH JOIN SEMI | | 78968 | 6863K| 21M| 1241 |
| 3 | TABLE ACCESS FULL | O | 232K| 19M| | 548 |
| 4 | TABLE ACCESS FULL | O2 | 78968 | 231K| | 102 |
----------------------------------------------------------------------------
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter(ROWNUM<20)
2 - access("O"."OBJECT_ID"="O2"."OBJECT_ID")
Note: cpu costing is off
已选择18行。
SQL> explain plan for select * from o where o.object_id in (select object_id fr
om o2);
已解释。
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost |
----------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 78968 | 6863K| | 1241 |
|* 1 | HASH JOIN SEMI | | 78968 | 6863K| 21M| 1241 |
| 2 | TABLE ACCESS FULL | O | 232K| 19M| | 548 |
| 3 | TABLE ACCESS FULL | O2 | 78968 | 231K| | 102 |
----------------------------------------------------------------------------
Predicate Information (identified by operation id):
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
---------------------------------------------------
1 - access("O"."OBJECT_ID"="O2"."OBJECT_ID")
Note: cpu costing is off
已选择16行。
SQL> |
|