Oracle分析query plan

來源:互聯網
上載者:User

清空Shared pool:

alter system flush shared_pool;

但為了整個記憶體的清空,只好將整個Oracle RAC環境的執行個體和資料庫都關機,再重新啟動。

可以採用清空buffer cache的方式來做:

alter system flush buffer_cache;

 

分析query plan,

explain plan for select * fromHZCZRK_JBXXB,HZCZRK_ZPXXB WHERE HZCZRK_JBXXB.RYID = HZCZRK_ZPXXB.RYID;

select plan_table_output fromtable(dbms_xplan.display());

得到結果:

| Id | Operation                    |Name              | Rows  | Bytes |TempSpc| Cost (%CPU)| Time    |

-----------------------------------------------------------------------------------------------------------

|  0| SELECT STATEMENT            |                    |  2898K|  572M|      |  240K (1)| 00:48:06 |

|  1|  MERGE JOIN                  |                    |  2898K|  572M|      |  240K (1)| 00:48:06 |

|  2|  TABLE ACCESS BY INDEX ROWID|HZCZRK_ZPXXB      |  2898K|  146M|      |  120K (1)| 00:24:07 |

|  3|    INDEX FULL SCAN          | INDEX_HZCZRK_ZPXXB |  2898K|      |      |  6771  (1)| 00:01:22 |

|*  4|  SORT JOIN                  |                    | 2898K|  425M|  2156M|  119K  (1)| 00:24:00 |

|  5|    TABLE ACCESS FULL        | HZCZRK_JBXXB      | 2898K|  425M|      | 21194  (3)| 00:04:15 |

-----------------------------------------------------------------------------------------------------------

 

Predicate Information (identified byoperation id):

---------------------------------------------------

 

  4-access("HZCZRK_JBXXB"."RYID"="HZCZRK_ZPXXB"."RYID")

      filter("HZCZRK_JBXXB"."RYID"="HZCZRK_ZPXXB"."RYID")

 

使用set autotrace traceonly後可以查看執行計畫、統計資訊,如query:

SELECT COUNT(*) FROM HZCZRK_JBXXB;,執行計畫、統計資訊如下:

------------------------------------------------------------------------------

| Id | Operation            |Name        | Rows  | Cost (%CPU)| Time    |

------------------------------------------------------------------------------

|  0| SELECT STATEMENT      |              |    1 | 9643  (2)| 00:01:56 |

|  1|  SORT AGGREGATE      |              |    1 |            |          |

|  2|  INDEX FAST FULL SCAN| SYS_C0010867|    17M| 9643  (2)| 00:01:56 |

------------------------------------------------------------------------------

 

 

統計資訊

----------------------------------------------------------

        1  recursive calls

        0  db block gets

      37509 consistent gets

    37485  physical reads

        0  redo size

      537  bytes sent via SQL*Net toclient

      524  bytes received via SQL*Netfrom client

        2  SQL*Net roundtrips to/fromclient

        0  sorts (memory)

        0  sorts (disk)

1        rows processed

consistent gets代表記憶體消耗,physicalreads代表磁碟I/O消耗,單位都是資料區塊(DB_BLOCK_SIZE)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.