查看执行计划event 10046和tkprof
上篇文章提到了用set autotrace和dbms_xplan去查看执行计划,下面我们将重点看看event 10046和tkprof来查看执行计划。 1 设置10046 event SQL> alter session set events '10046 trace name context forever ,level 12'; Session altered. SQL> select sum(o
上篇文章提到了用set autotrace和dbms_xplan去查看执行计划,下面我们将重点看看event 10046和tkprof来查看执行计划。
1 设置10046 event
SQL> alter session set events '10046 trace name context forever ,level 12';
Session altered.
SQL> select sum(object_id),sum(data_object_id) from t01;
SUM(OBJECT_ID) SUM(DATA_OBJECT_ID)
-------------- -------------------
1283335921 97173652
SQL> alter session set events '10046 trace name context off';
Session altered.
10046 event的raw trace文件:
Dump file g:\oracle\product\10.2.0\admin\ora10g\udump\ora10g_ora_1352.trc
Thu May 22 22:22:16 2014
ORACLE V10.2.0.4.0 - 64bit Production vsnsta=0
vsnsql=14 vsnxtr=3
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Windows NT Version V6.1
CPU : 4 - type 8664, 2 Physical Cores
Process Affinity : 0x0000000000000000
Memory (Avail/Total): Ph:4370M/7889M, Ph+PgF:10433M/15777M
Instance name: ora10g
Redo thread mounted by this instance: 1
Oracle process number: 115
Windows thread id: 1352, image: ORACLE.EXE (SHAD)
。。。
*** 2014-05-22 22:22:35.371
=====================
PARSING IN CURSOR #11 len=50 dep=0 uid=58 oct=3 lid=58 tim=12339600047 hv=887579624 ad='5d666250'
select sum(object_id),sum(data_object_id) from t01
END OF STMT
PARSE #11:c=0,e=1484,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=1,tim=12339600040
BINDS #11: --10046 trace中还会记录bind value,这里由于没有使用bind,所以下面没有列出
EXEC #11:c=0,e=385,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=12339602189
WAIT #11: nam='SQL*Net message to client' ela= 4 driver id=1111838976 #bytes=1 p3=0 obj#=-1 tim=12339602537
FETCH #11:c=15601,e=15187,p=0,cr=693,cu=0,mis=0,r=1,dep=0,og=1,tim=12339618068
WAIT #11: nam='SQL*Net message from client' ela= 370 driver id=1111838976 #bytes=1 p3=0 obj#=-1 tim=12339619256
FETCH #11:c=0,e=1,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=0,tim=12339619716
WAIT #11: nam='SQL*Net message to client' ela= 3 driver id=1111838976 #bytes=1 p3=0 obj#=-1 tim=12339620145
WAIT #11: nam='SQL*Net message from client' ela= 8040398 driver id=1111838976 #bytes=1 p3=0 obj#=-1 tim=12347660914
STAT #11 id=1 cnt=1 pid=0 pos=1 obj=0 op='SORT AGGREGATE (cr=693 pr=0 pw=0 time=15180 us)'
STAT #11 id=2 cnt=50070 pid=1 pos=1 obj=51887 op='TABLE ACCESS FULL T01 (cr=693 pr=0 pw=0 time=84 us)'
下面小鱼将结合部分资料对这个10046 event进行解读:
PARSING IN CURSOR #11 len=50 dep=0 uid=58 oct=3 lid=58 tim=12339600047 hv=887579624 ad='5d666250'
先看上面的的parsing in cursor部分:
其中的parsing in cursor表示的游标编号,这里是11
Len表示的是被解析的sql语句长度
Dep表示的递归sql语句的深度
Uid是user_id,对应于dba_users的user_id
Oct表示oracle command type类型
Lid表示私有用户id
Tim表示时间戳
Hv表示的sql的hash_value
Ad表示的sql的address
BINDS #11: --10046 trace中还会记录bind value,这里由于没有使用bind,所以下面没有列出
再来看parse、exec和fetch部分:
PARSE #11:c=0,e=1484,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=1,tim=12339600040
EXEC #11:c=0,e=385,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=12339602189
FETCH #11:c=15601,e=15187,p=0,cr=693,cu=0,mis=0,r=1,dep=0,og=1,tim=12339618068
FETCH #11:c=0,e=1,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=0,tim=12339619716
C表示消耗的cpu time
E表示消耗的事件
P表示物理读
Cr表示一致性读
Mis表示硬解析次数
R表示处理的行数
Dep表示递归sql的深度
Og optimizer goal表示优化器模式
Time表示时间戳
Stat部分:
STAT #11 id=1 cnt=1 pid=0 pos=1 obj=0 op='SORT AGGREGATE (cr=693 pr=0 pw=0 time=15180 us)'
STAT #11 id=2 cnt=50070 pid=1 pos=1 obj=51887 op='TABLE ACCESS FULL T01 (cr=693 pr=0 pw=0 time=84 us)'
Id表示执行计划id
Cnt表示cardinality
Pid表示行源号的父号
Pos执行计划中的位置
Obj表示的是对象的object_id
Op表示执行计划的中返回方式
Cr表示的一致性读取
Pr表示的物理读
Pw表示的物理写
Time表示消耗的时间,这里的us是微妙,1s=1000ms=1000*1000us
STAT包含了完整的执行计划,10046 event trace也能看见完整的执行计划,还能看见各个执行步骤消耗的步骤,比如一致性读、物理读写,消耗的时间,相比dbms_xplan、autotrace更加清晰和明了。
Level 12 10046 trace文件中还记录了一个比较重要的信息就是等待事件,分别记录了sql解析,执行和获取数据时各自的等待事件,比如上述这个sql语句还记录了sql语句执行的过程(解析-执行-获取数据)的伴随着sql*net message to client和sql*net message from client等待。
大家如果能直接看懂10046 event的trace更好,如果看不懂oracle也推出了tkprof用来简化原始的10046 event trace文件,使用办法也很简单。
C:\Users\Administrator>tkprof
Usage: tkprof tracefile outputfile [explain= ] [table= ]
[print= ] [insert= ] [sys= ] [sort= ]
table=schema.tablename Use 'schema.tablename' with 'explain=' option.
explain=user/password Connect to ORACLE and issue EXPLAIN PLAN.
print=integer List only the first 'integer' SQL statements.
aggregate=yes|no
insert=filename List SQL statements and data inside INSERT statements.
sys=no TKPROF does not list SQL statements run as user SYS.
record=filename Record non-recursive statements found in the trace file.
waits=yes|no Record summary for any wait events found in the trace file.
sort=option Set of zero or more of the following sort options:
prscnt number of times parse was called
prscpu cpu time parsing
prsela elapsed time parsing
prsdsk number of disk reads during parse
prsqry number of buffers for consistent read during parse
prscu number of buffers for current read during parse
prsmis number of misses in library cache during parse
execnt number of execute was called
execpu cpu time spent executing
exeela elapsed time executing
exedsk number of disk reads during execute
exeqry number of buffers for consistent read during execute
execu number of buffers for current read during execute
exerow number of rows processed during execute
exemis number of library cache misses during execute
fchcnt number of times fetch was called
fchcpu cpu time spent fetching
fchela elapsed time fetching
fchdsk number of disk reads during fetch
fchqry number of buffers for consistent read during fetch
fchcu number of buffers for current read during fetch
fchrow number of rows fetched
userid userid of user that parsed the cursor
小鱼一般喜欢加上sys=no和aggregate=no,sys默认是yes,意为也捕捉sys用户的操作,而aggreagte是将相同的sql语句集合评估。
C:\Users\Administrator>tkprof G:\oracle\product\10.2.0\admin\ora10g\udump\ora10g_ora_1352.trc g:\tkprof_10046.txt sys=no aggregate=no explain=xiaoyu/xiaoyu
TKPROF: Release 10.2.0.4.0 - Production on Thu May 22 23:39:57 2014
Copyright (c) 1982, 2007, Oracle. All rights reserved.
生成的tkprof文件如下:
TKPROF: Release 10.2.0.4.0 - Production on Thu May 22 23:39:57 2014
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Trace file: G:\oracle\product\10.2.0\admin\ora10g\udump\ora10g_ora_1352.trc
Sort options: default
********************************************************************************
count = number of times OCI procedure was executed 执行的次数
cpu = cpu time in seconds executing 消耗cpu时间,单位秒
elapsed = elapsed time in seconds executing 消耗的总时间,单位秒
disk = number of physical reads of buffers from disk 物理读
query = number of buffers gotten for consistent read 一致性读
current = number of buffers gotten in current mode (usually for update) 当前读
rows = number of rows processed by the fetch or execute call 返回的rows
********************************************************************************
select sum(object_id),sum(data_object_id)
from
t01
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.01 0.01 0 693 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.01 0.01 0 693 0 1
Misses in library cache during parse: 1 --miss in library cache表示的是硬解析
Optimizer mode: ALL_ROWS --优化器模式
Parsing user id: 58 --解析的userid
--执行计划,其中rows表示的每步执行步骤对应的cardinality,cr表示的消耗的一致性读取,pr表示的物理读,pw表示物理写,time表示消耗的时间
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE (cr=693 pr=0 pw=0 time=15180 us)
50070 TABLE ACCESS FULL T01 (cr=693 pr=0 pw=0 time=84 us)
在sql语句中的等待事件。
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 2 0.00 0.00
SQL*Net message from client 2 8.04 8.04
********************************************************************************
alter session set events '10046 trace name context off'
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 2 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
Parsing user id: 58
下面是系统递归sql语句和非递归sql语句的消耗的资源和等待事件,递归sql语句表示的是sql语句执行过程中需要读取一些数据字典而产生的sql语句
********************************************************************************
OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 2 0.00 0.00 0 0 0 0
Execute 2 0.00 0.00 0 0 0 0
Fetch 2 0.01 0.01 0 693 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 6 0.01 0.01 0 693 0 1
Misses in library cache during parse: 1
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 3 0.00 0.00
SQL*Net message from client 3 18.54 26.58
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 0 0.00 0.00 0 0 0 0
Execute 0 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 0 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
2 user SQL statements in session.
0 internal SQL statements in session.
2 SQL statements in session.
********************************************************************************
Trace file: G:\oracle\product\10.2.0\admin\ora10g\udump\ora10g_ora_1352.trc
Trace file compatibility: 10.01.00
Sort options: default
1 session in tracefile.
2 user SQL statements in trace file.
0 internal SQL statements in trace file.
2 SQL statements in trace file.
2 unique SQL statements in trace file.
50 lines in trace file.
8 elapsed seconds in trace file.
原文地址:查看执行计划event 10046和tkprof, 感谢原作者分享。

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

1.先點選開啟抖音app,點選【我】。 2.點選右上方三點的圖示。 3.點選進入【設定】。 4.點選開啟【帳號與安全】。 5.選擇點選【登入設備管理】。 6.最後點選選擇其中的設備,點選【移除】即可。

1.打開手機後,選擇網路易雲音樂。 2.進入首頁後,大家就可以看到【排行榜】,點選進入。 3.在排行榜中,可以選擇任意榜單,點選【新歌榜】。 4、選擇自己喜歡的歌曲,並進行點擊。 5.返回上一頁,可以看到更多的榜單。

快手直播伴侶不僅是一個強大的直播輔助工具,更是一個為主播們打造的即時熱門話題和趨勢的洞察平台。透過這個功能,主播可以快速捕捉觀眾目前最關注的內容,進而調整直播內容,使其更符合觀眾的品味和興趣。那麼在快手直播伴侶app中如何查看影片熱榜呢,這篇教學攻略就將為大家帶來詳細的步驟介紹,希望能幫助到大家。快手直播伴侶怎麼看影片熱榜第二步,點選每日影片熱榜。第三步,即可查看每日影片熱榜了。

閒魚作為交易平台,使用前都需要先註冊和登入自己的帳號,用戶可以為自己的帳號設定id名稱,如果想查看自己的id是什麼怎麼辦呢?下面就來一起了解吧!閒魚個人暱稱檢視方法介紹先啟動閒魚應用,進入首頁後,透過切換到賣閒置、訊息、我的頁面,點選右下角的【我的】選項。 2、然後在我的頁面中我們需要點擊左上角的【頭像】;2、接著來到個人主頁的頁面中可以看到不同的信息,我們需要在這裡點擊【編輯資料】按鈕;4、最後點擊過後在編輯資料的頁面中我們就可以看到了;

無論生活或工作,很多人早已被微信深深捆綁,隨時會被拉入各種各樣的群,那麼你到底加入了多少微信群呢?你可能會立刻想要查看通訊錄中的群聊,但只有你保存在通訊錄中的微信群才會顯示在那裡,其他群是不可見的。想看自己加入的所有微信群,也非常簡單:在微信首頁搜尋框輸入您的暱稱,然後在搜尋結果中找到群組聊天部分,點擊「更多群組聊天」即可查看所有相關群組聊天資訊。反正我是被嚇了一跳,密密麻麻上百個都不止,右側滾動條都變得很小了。只可惜,沒有具體數量統計…這個方法也同樣適用於查看加入的QQ群。 PS:還有網友提供了一招,

微信群組聊天這裡不僅是一個簡單的聊天平台,更是一個匯集了各行各業精英和熱心朋友的交流圈,所以小編今天就來教大家微信看自己加了多少群及保存群聊方法,平時使用微信的用戶可千萬不要錯過了喲。微信看自己加了多少群及保存群聊方法微信查看自己加了多少群:1.您可在微信主界面中查看你的群聊窗口2.若您已經操作保存群聊,您可輕觸【通訊錄】-【群組聊天】3.群組進入後即可查看到已儲存的群組裡啦保存微信群組:1.選擇您需儲存的群組裡,右上方【...】2.聊天訊息中打開【儲存到通訊錄】3.微信主介面,輕觸【通訊錄】-【群組聊天】即可查看

中關村消息:4月18日早上,華為突然宣布P70系列手機開啟先鋒計畫正式開售,想要購買的朋友要準備行動起來了,按照以往慣例,華為的旗艦手機非常搶手,會一直處於缺貨狀態。這次華為P70系列改名為Pura,意為純粹。在此前華為餘承東表示:自2012年起,華為P系列智慧型手機便如同忠實的伙伴,伴隨全球億萬用戶度過了無數珍貴時刻,共同見證了生活中的美好與精彩紛呈。他深刻感悟,每位選擇華為P系列的用戶所給予的信任與熱愛,無異於一股強大的推動力,始終鼓舞著華為在創新之路上堅定前行。 Pura的意思是純粹的。

1、我們先打開高德地圖。 2、然後在高德地圖的主頁中點選右下角的(我的)隨後點選右上角的設定。 3.最後這樣就可以看到高德地圖的幫助中心了。
