同之前聊过的 Group By 配置最优机能同等的,还有 Distinct 配置最优机能(Distinct Placement)
Distinct 配置最优机能(Distinct Placement)
还是用下面的 Test case 进行简单的演示,说明一下 Distinct Placement 动作时执行计划的样子。
drop table t1 purge;
drop table t2 purge;
create table t1(c1 number, c2 number not null);
create table t2(c1 number, c2 number not null);
insert into t1 values (1,1);
insert into t1 values (1,2);
insert into t1 values (2,2);
insert into t2 values (1,2);
commit;
SQL> SQL> select /*+ place_distinct(t2) */
distinct t1.c2, t2.c2
from t1, t2
where t1.c1 = t2.c1; 2 3 4
C2 C2
---------- ----------
1 2
2 2
Execution Plan
----------------------------------------------------------
Plan hash value: 107983552
-----------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 2 | 104 | 8 (25)| 00:00:01 |
| 1 | HASH UNIQUE | | 2 | 104 | 8 (25)| 00:00:01 |
|* 2 | HASH JOIN | | 2 | 104 | 7 (15)| 00:00:01 |
| 3 | VIEW | VW_DTP_AE9E49E8 | 1 | 26 | 4 (25)| 00:00:01 |
| 4 | HASH UNIQUE | | 1 | 26 | 4 (25)| 00:00:01 |
| 5 | TABLE ACCESS FULL| T2 | 1 | 26 | 3 (0)| 00:00:01 |
| 6 | TABLE ACCESS FULL | T1 | 3 | 78 | 3 (0)| 00:00:01 |
-----------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("T1"."C1"="ITEM_1")
Note
-----
- dynamic sampling used for this statement (level=2)
特征是使用了内部转换的试图 VW_DTP_*。
关闭此功能的方法是 "_optimizer_distinct_placement" = false。