查看执行计划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 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제











1. 먼저 클릭하여 Douyin 앱을 열고 [나]를 클릭하세요. 2. 오른쪽 상단에 있는 점 3개 아이콘을 클릭하세요. 3. 클릭하여 [설정]으로 들어갑니다. 4. [계정 및 보안]을 클릭하여 엽니다. 5. [장치 관리에 로그인]을 선택하고 클릭하세요. 6. 마지막으로 장치를 클릭하여 선택하고 [제거]를 클릭하세요.

Xianyu는 거래 플랫폼으로서 사용하기 전에 계정에 등록하고 로그인해야 합니다. 사용자는 자신의 계정에 대한 ID 이름을 설정할 수 있습니다. 아래에서 함께 알아볼까요! Xianyu에서 개인 닉네임을 확인하는 방법을 소개합니다. 먼저 Xianyu 앱을 시작하고, 홈페이지에 진입한 후 방치, 메시지, 나 판매 페이지로 전환한 후 오른쪽 하단의 [내] 옵션을 클릭합니다. 2. 그런 다음 내 페이지의 왼쪽 상단에 있는 [아바타]를 클릭해야 합니다. 2. 그런 다음 개인 홈페이지로 이동하면 여기에서 [정보 편집] 버튼을 클릭해야 합니다. 4. 마지막으로 정보를 편집하는 페이지에서 나중에 볼 수 있음을 클릭합니다.

1. 휴대폰을 켠 후 NetEase Cloud Music을 선택합니다. 2. 홈페이지에 입장하시면 누구나 [랭킹리스트]를 확인하실 수 있으며, 클릭하시면 입장 가능합니다. 3. 순위 목록에서 원하는 목록을 선택한 후 [신곡 목록]을 클릭하세요. 4. 좋아하는 노래를 선택하고 클릭하세요. 5. 더 많은 목록을 보려면 이전 페이지로 돌아가세요.

Kuaishou Live Companion은 강력한 라이브 방송 보조 도구일 뿐만 아니라 방송사를 위해 만들어진 인기 주제와 트렌드에 대한 실시간 통찰력 플랫폼이기도 합니다. 이 기능을 통해 앵커는 시청자가 가장 궁금해하는 콘텐츠를 빠르게 포착한 뒤, 시청자의 취향과 관심에 더욱 부합하도록 라이브 콘텐츠를 조정할 수 있다. 그렇다면 Kuaishou Live Companion 앱에서 인기 동영상 목록을 확인하는 방법은 무엇입니까? 이 튜토리얼 가이드가 귀하에게 도움이 되기를 바랍니다. Kuaishou Live Companion에서 핫 비디오 목록을 보는 방법 두 번째 단계는 일일 비디오 핫 목록을 클릭하는 것입니다. 세 번째 단계는 일일 영상 핫리스트를 확인하는 것입니다.

WeChat 그룹 채팅은 단순한 채팅 플랫폼일 뿐만 아니라 각계각층의 엘리트와 열성적인 친구들을 하나로 모으는 커뮤니케이션 서클입니다. 그래서 오늘은 WeChat에 추가한 그룹 수를 확인하는 방법과 저장하는 방법을 알려드리겠습니다. 일반적으로 WeChat을 사용하는 사용자는 놓치지 마세요. WeChat에 추가한 그룹 수를 확인하는 방법 및 그룹 채팅을 저장하는 방법 WeChat에 추가한 그룹 수를 확인하려면: 1. WeChat 기본 인터페이스에서 그룹 채팅 창을 볼 수 있습니다. 2. 이미 저장한 경우 그룹 채팅은 [주소록] - [그룹 채팅]을 누르시면 됩니다. 3. 그룹 채팅에 진입하신 후 저장된 그룹을 보실 수 있습니다. 위챗 그룹 저장: 1. 오른쪽 상단 [.. .] 2. 채팅 메시지 열기 [주소록에 저장] 3. 위챗 메인 인터페이스에서 [주소록]-[그룹 채팅]을 눌러 확인하세요.

삶이나 일에 관계없이 많은 사람들이 오랫동안 WeChat에 깊이 연결되어 있으며 언제든지 다양한 그룹에 참여하게 될 것입니다. 그러면 얼마나 많은 WeChat 그룹에 가입하셨나요? 주소록에 있는 그룹 채팅을 즉시 보고 싶을 수도 있지만 주소록에 저장한 WeChat 그룹만 여기에 표시되고 다른 그룹은 표시되지 않습니다. 가입한 모든 WeChat 그룹을 보려면 매우 간단합니다. WeChat 홈페이지의 검색창에 닉네임을 입력한 다음 검색 결과에서 그룹 채팅 섹션을 찾아 "그룹 채팅 더보기"를 클릭하면 됩니다. 관련된 모든 그룹 채팅 정보. 암튼 100개도 넘게 있었는데, 오른쪽 스크롤바가 엄청 작아져서 놀랐습니다. 아쉽게도 구체적인 숫자 통계는 없습니다... 이 방법은 귀하가 가입한 QQ 그룹을 확인하는 데에도 적용됩니다. 추신: 일부 네티즌들은 다음과 같은 트릭도 제공했습니다.

1. 먼저 Gaode 지도를 엽니다. 2. Amap 홈페이지 우측 하단의 (내)를 클릭하신 후, 우측 상단의 설정을 클릭하세요. 3. 마지막으로 Amap의 도움말 센터를 볼 수 있습니다.

중관촌 뉴스: 4월 18일 오전, 화웨이는 갑자기 P70 시리즈 휴대폰이 파이오니어 플랜에 따라 공식적으로 판매된다고 발표했습니다. 구매를 원하는 친구들은 과거 관행에 따르면 화웨이의 주력 휴대폰을 준비해야 합니다. 인기가 많아 항상 품절 상태입니다. 이번에 Huawei P70 시리즈는 순수함을 의미하는 Pura로 이름이 변경되었습니다. 이전에 Huawei의 Yu Chengdong은 다음과 같이 말했습니다. 2012년부터 Huawei의 P 시리즈 스마트폰은 전 세계 수억 명의 사용자와 함께 수많은 소중한 순간을 보내고 삶의 아름다움과 흥분을 함께 목격하는 충실한 파트너와 같습니다. 그는 화웨이 P 시리즈를 선택하는 모든 사용자가 제공하는 신뢰와 사랑이 화웨이가 혁신의 길에서 굳건히 전진할 수 있도록 항상 격려하는 강력한 원동력과 같다고 깊이 느꼈습니다. 푸라(Pura)는 순수하다는 뜻이다.
