当前位置:网站首页>Oracle性能分析3:TKPROF简介
Oracle性能分析3:TKPROF简介
2022-07-06 13:45:00 【全栈程序员站长】
大家好,又见面了,我是全栈君。
tkprof它是Oracle它配备了一个命令直插式工具,其主要作用是将原始跟踪文件格文本文件的类型,例如,最简单的方法,使用下面的:
tkprof ly_ora_128636.trc ly_ora_128636.txt
tkprof带有非常多參数,在多数情况下,使用这些參数对你的分析将非常有帮助。
tkprof參数
假设不带不论什么參数执行tkprof,它将打印出完整的參数列表,并带有简单的描写叙述。以下是对參数的说明:
explain 为每一个SQL语句提供一个运行计划。
该參数须要指定用户、密码。也能够指定数据库连接串,如:explain=user/[email protected]_string或者explain=user/password。
table 纸盒explain參数一起使用,用于指定生成运行计划使用的表,通常不须要指定,仅仅有当用户不能创建表时才须要(如缺少create table权限)。 print 用于限制输出文件生成的SQL语句的数量,比如:print=10. aggregate 指定是否单独处理相同内容的SQL语句。默认不单独处理。指定为aggregate=no,看单独的每一个SQL语句。
insert 生成SQL脚本,SQL脚本能够用来存储信息到数据库中,SQL脚本的名字由參数指定,如:insert=load.sql。 sys 指定sys用户执行的SQL语句是否也写入到输出文件里,默认yes。
record 生成SQL脚本。里面包括在trace文件里找到的全部非递归语句,脚本名通过參数本身来指定。比如:record=replay.sql。
waits 是否加入等待事件的信息,默认加入。 sort 指定写入输出文件里的SQL语句的顺序。默认是trace文件里发现的SQL顺序。
以下是一个样例:
tkprof {input trace file} {output file} sys=no sort=prsela,exeela,fchela
prsela:第一个游标解析耗费的时间 exeela:针对游标运行花费的时间 fchela:游标获取数据行所花费的时间
tkprof输出
输出文件带有一个头,当中有对參数的说明。例如以下:
**********************************************************************
count = number of times OCI procedure was executed
cpu = cpu time in seconds executing
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
**********************************************************************
count:运行的数据库调用次数 cpu:处理数据调用花去的CPU时间,以秒为单位 elapsed:处理数据库调用花费的总的时间,以秒为单位 disk:物理读的数据块数量,假设大于逻辑读的数量(disk>query+current),表示使用了暂时表空间。
query:在一致性模式下从快速缓存逻辑读取的快数量。用作查询。 current:在当前模式下从快速缓存逻辑读取的块数量,用于insert、delete、merge以及update等操作。 rows:处理的数据行数量。查询表示获取的行数量。而insert、delete、merge以及update等则表示影响的行数量。
以下看一个详细的样例:
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 501 0.03 0.15 0 1465 0 50001
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 503 0.03 0.15 0 1465 0 50001
上面分别相应了parse、execute和fetch这3个阶段。在fetch阶段运行了501次fetch,获取了50001行数据,每次fetch获取100行数据。 接下来是:
Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: ALL_ROWS
Parsing user id: 5
前两行表示发生在解析和运行调用阶段的硬解析数量。假设没有硬解析。则不存在。 “Optimizer mode”表示优化器模式。
“Parsing user id”是解析SQL语句的用户。 在这之后能够看到运行计划,这里仅仅做一个简单解说:
Rows Row Source Operation
------- ---------------------------------------------------
50001 COUNT STOPKEY (cr=1465 pr=0 pw=0 time=300125 us)
50001 VIEW (cr=1465 pr=0 pw=0 time=200088 us)
50001 INDEX FULL SCAN IDX_HISTORYALARM$CLEAR (cr=1465 pr=0 pw=0 time=100049 us)(object id 53743)
cr:一致性模式下逻辑读出的数据块数 pr:从磁盘物理读出的数据块数 pw:物理写入磁盘的数据块数 time:以微妙表示的总的耗费时间,注意数据不精确 cost:操作的评估开销(仅11g才提供) size:操作返回的预预计数据量(字节数)(仅11g才提供) card:操作返回的预预计行数(仅11g才提供)
接下来就是等待事件:
Event waited on Times Waited Max. Wait Total Waited
----------------------------------------------------------------------------------
SQL*Net message to client 502 0.00 0.00
SQL*Net message from client 502 0.08 15.42
SQL*Net more data to client 500 0.00 0.01
Times Waited:等待时间占用时间 Max. Wait:单个等待事件最大等待时间,单位为秒 Total Waited:针对一个等待事件总的等待秒数。不精确
这里你能够看到运行中遇到的等待事件,通过对这些等待事件的分析。有助于你了解在等待什么样的资源,查询的瓶颈,有针对的做出优化。
能够在Oracle Database Reference在一份简短的叙述中附录的手册描述了最常见的等待事件。
版权声明:本文博主原创文章。博客,未经同意不得转载。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/117071.html原文链接:https://javaforall.cn
边栏推荐
- guava:Collections.unmodifiableXXX创建的collection并不immutable
- 在Pi和Jetson nano上运行深度网络,程序被Killed
- 十一、服务介绍及端口
- The underlying implementation of string
- [go][reprint]vscode run a HelloWorld example after configuring go
- Write a rotation verification code annotation gadget with aardio
- Run the deep network on PI and Jetson nano, and the program is killed
- [daily] win10 system setting computer never sleeps
- Binary tree node at the longest distance
- 在最长的距离二叉树结点
猜你喜欢
随机推荐
Leetcode learning records (starting from the novice village, you can't kill out of the novice Village) ---1
小满网络模型&http1-http2 &浏览器缓存
[asp.net core] set the format of Web API response data -- formatfilter feature
Numpy download and installation
[Li Kou brush questions] 32 Longest valid bracket
Vit paper details
guava: Multiset的使用
互联网快讯:吉利正式收购魅族;胰岛素集采在31省全面落地
Acdreamoj1110 (multiple backpacks)
The underlying implementation of string
Microsoft technology empowerment position - February course Preview
首批入选!腾讯安全天御风控获信通院业务安全能力认证
技术分享 | 抓包分析 TCP 协议
[go][reprint]vscode run a HelloWorld example after configuring go
Guava: three ways to create immutablexxx objects
Technology sharing | packet capturing analysis TCP protocol
Hill | insert sort
麦趣尔砸了小众奶招牌
关于程序员的职业操守,从《匠艺整洁之道》谈起
Explain ESM module and commonjs module in simple terms