淺析Oracle 10gR2中最佳化器對錶關聯的最佳化

來源:互聯網
上載者:User

 在以前的一篇文章中,介紹過額外的關聯對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)

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.