Oracle 工具:tkprof

來源:互聯網
上載者:User

1 定義

用於分析Oracle追蹤檔案並且可按需產生一個更加清晰合理的輸出結果的可執行工具

2 喜好設定

  1. F:\>tkprof  
  2. Usage: tkprof tracefile outputfile [explain= ] [table= ]  
  3.               [print= ] [insert= ] [sys= ] [sort= ]  
  4.   table=schema.tablename   Use 'schema.tablename' with 'explain=' option.  
  5.   explain=user/password    Connect to ORACLE and issue EXPLAIN PLAN.  
  6.   print=integer    List only the first 'integer' SQL statements.  
  7.   aggregate=yes|no  
  8.   insert=filename  List SQL statements and data inside INSERT statements.  
  9.   sys=no           TKPROF does not list SQL statements run as user SYS.  
  10.   record=filename  Record non-recursive statements found in the trace file.  
  11.   waits=yes|no     Record summary for any wait events found in the trace file.  
  12.   sort=option      Set of zero or more of the following sort options:  
  13.     prscnt  number of times parse was called  
  14.     prscpu  cpu time parsing  
  15.     prsela  elapsed time parsing  
  16.     prsdsk  number of disk reads during parse  
  17.     prsqry  number of buffers for consistent read during parse  
  18.     prscu   number of buffers for current read during parse  
  19.     prsmis  number of misses in library cache during parse  
  20.     execnt  number of execute was called  
  21.     execpu  cpu time spent executing  
  22.     exeela  elapsed time executing  
  23.     exedsk  number of disk reads during execute  
  24.     exeqry  number of buffers for consistent read during execute  
  25.     execu   number of buffers for current read during execute  
  26.     exerow  number of rows processed during execute  
  27.     exemis  number of library cache misses during execute  
  28.     fchcnt  number of times fetch was called  
  29.     fchcpu  cpu time spent fetching  
  30.     fchela  elapsed time fetching  
  31.     fchdsk  number of disk reads during fetch  
  32.     fchqry  number of buffers for consistent read during fetch  
  33.     fchcu   number of buffers for current read during fetch  
  34.     fchrow  number of rows fetched  
  35.     userid  userid of user that parsed the cursor  

注釋:

① fchela這是個比較有用的sort選項,在產生的.prf檔案將把最消耗時間的sql放在最前面顯示

② sys=no 以sys身份執行的sql不會被顯示,增加可讀性

3 tkprof輸出檔案中各列的含義

  1. call     count       cpu    elapsed       disk      query    current        rows  
  2. ------- ------  -------- ---------- ---------- ---------- ----------  ----------  

注釋:

㈠ call:

每次sql的處理都分成3個部分

① parse:將sql語句轉成執行計畫,包括檢查許可權、表及其關聯對象是否存在等

② execute:由sql引擎執行,因事務類型不同而異

③ fetch:這步只有select語句被執行,buffer cache是主戰場

㈡ count:

這條sql被parse、execute和fetch的次數

㈢ cpu:該sql語句所消耗的cpu的時間(單位:s)

㈣ elapsed:該sql語句在各個階段的執行時間

㈤ disk:

從磁碟上的資料檔案中物理讀取的塊的數量

㈥ query:

在一致性讀的模式下,各階段所獲得的buffer的數量。一致性模式下,buffer是用於給一個長查詢提供一致性

讀的快照

㈦ current:

在當前讀的模式下,各階段所獲得的buffer的數量。

㈧ rows:

所有的sql返回的記錄數目,但不包括子查詢返回的記錄。

對於select語句,返回是在fetch這步

對於DML語句,返回是在execute這步

  • 1
  • 2
  • 3
  • 4
  • 下一頁

聯繫我們

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