在以前的一篇文章中,介紹過額外的關聯對SQL的影響是很大的,所以在sql審核的工作中,對於表關聯的關注是相當多的,如果冗餘能夠最佳化掉表關聯,偶都盡量在表設計上做些冗餘處理;在10gR2中,發現最佳化器可以最佳化掉一些不必要的關聯……
9206:
SQL> set autot on
SQL> select count(*)
2 from dept d, emp e
3 where d.deptno = e.deptno;
COUNT(*)
----------
12
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE
1 0 SORT (AGGREGATE)
2 1 NESTED LOOPS
3 2 TABLE ACCESS (FULL) OF 'EMP'
4 2 INDEX (UNIQUE SCAN) OF 'PK_DEPT' (UNIQUE)
10202
SQL> set autot on
SQL> select count(*)
2 from dept d, emp e
3 where d.deptno = e.deptno;
COUNT(*)
----------
12
ִѐ¼ƻ
----------------------------------------------------------
Plan hash value: 2083865914
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 13 | 3 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 13 | | |
|* 2 | TABLE ACCESS FULL| EMP | 12 | 156 | 3 (0)| 00:00:01 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - filter("E"."DEPTNO" IS NOT NULL)