- 最后登录
- 2023-8-16
- 在线时间
- 1686 小时
- 威望
- 2135
- 金钱
- 50532
- 注册时间
- 2011-10-12
- 阅读权限
- 200
- 帖子
- 5207
- 精华
- 39
- 积分
- 2135
- UID
- 2
|
3#
发表于 2013-1-14 22:13:24
- SQL>
- SQL> create table emp as select * from scott.emp;
- Table created.
- SQL> create table dept as select * from scott.dept;
- Table created.
- SQL> create index pk_dept on dept(deptno);
- Index created.
- select ename
- from emp A
- where not exists (select 1 from dept B where A.deptno = B.deptno);
-
-
-
- Execution Plan
- ----------------------------------------------------------
- Plan hash value: 576271144
- ------------------------------------------------------------------------------
- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
- ------------------------------------------------------------------------------
- | 0 | SELECT STATEMENT | | 1 | 33 | 2 (0)| 00:00:01 |
- | 1 | NESTED LOOPS ANTI | | 1 | 33 | 2 (0)| 00:00:01 |
- | 2 | TABLE ACCESS FULL| EMP | 14 | 280 | 2 (0)| 00:00:01 |
- |* 3 | INDEX RANGE SCAN | PK_DEPT | 4 | 52 | 0 (0)| 00:00:01 |
- ------------------------------------------------------------------------------
- Predicate Information (identified by operation id):
- ---------------------------------------------------
- 3 - access("A"."DEPTNO"="B"."DEPTNO")
- Note
- -----
- - dynamic sampling used for this statement
- Statistics
- ----------------------------------------------------------
- 0 recursive calls
- 0 db block gets
- 5 consistent gets
- 0 physical reads
- 0 redo size
- 322 bytes sent via SQL*Net to client
- 481 bytes received via SQL*Net from client
- 1 SQL*Net roundtrips to/from client
- 0 sorts (memory)
- 0 sorts (disk)
- 0 rows processed
-
-
-
- SQL> oradebug setmypid
- Statement processed.
- SQL> oradebug event 10053 trace name context forever,level 1;
- Statement processed.
- SQL> explain plan for select ename
- 2 from emp A
- 3 where not exists (select 1 from dept B where A.deptno = B.deptno);
- Explained.
- ******* UNPARSED QUERY IS *******
- SELECT "A"."ENAME" "ENAME" FROM "SYS"."DEPT" "B","SYS"."EMP" "A" WHERE "A"."DEPTNO"="B"."DEPTNO"
- kkoqbc-subheap (delete addr=0x7f99d52f16f8, in-use=23080, alloc=23736)
- kkoqbc-end
- : call(in-use=22344, alloc=65552), compile(in-use=57328, alloc=106032)
- apadrv-end: call(in-use=22344, alloc=65552), compile(in-use=58312, alloc=106032)
- sql_id=frvs2rfn4z4g3.
- Current SQL statement for this session:
- explain plan for select ename
- from emp A
- where not exists (select 1 from dept B where A.deptno = B.deptno)
- ============
- Plan Table
- ============
- --------------------------------------+-----------------------------------+
- | Id | Operation | Name | Rows | Bytes | Cost | Time |
- --------------------------------------+-----------------------------------+
- | 0 | SELECT STATEMENT | | | | 2 | |
- | 1 | NESTED LOOPS ANTI | | 1 | 33 | 2 | 00:00:01 |
- | 2 | TABLE ACCESS FULL | EMP | 14 | 280 | 2 | 00:00:01 |
- | 3 | INDEX RANGE SCAN | PK_DEPT | 4 | 52 | 0 | |
- --------------------------------------+-----------------------------------+
- Predicate Information:
- ----------------------
- 3 - access("A"."DEPTNO"="B"."DEPTNO")
-
复制代码 对于ANTI JOIN来说 其原理要求driving table为特定表 |
|