当前位置:网站首页>Oracle性能分析3:TKPROF简介
Oracle性能分析3:TKPROF简介
2022-07-06 13:45:00 【全栈程序员站长】
大家好,又见面了,我是全栈君。
tkprof它是Oracle它配备了一个命令直插式工具,其主要作用是将原始跟踪文件格文本文件的类型,例如,最简单的方法,使用下面的:
tkprof ly_ora_128636.trc ly_ora_128636.txttkprof带有非常多參数,在多数情况下,使用这些參数对你的分析将非常有帮助。
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,fchelaprsela:第一个游标解析耗费的时间 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.01Times Waited:等待时间占用时间 Max. Wait:单个等待事件最大等待时间,单位为秒 Total Waited:针对一个等待事件总的等待秒数。不精确
这里你能够看到运行中遇到的等待事件,通过对这些等待事件的分析。有助于你了解在等待什么样的资源,查询的瓶颈,有针对的做出优化。
能够在Oracle Database Reference在一份简短的叙述中附录的手册描述了最常见的等待事件。
版权声明:本文博主原创文章。博客,未经同意不得转载。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/117071.html原文链接:https://javaforall.cn
边栏推荐
- [daily] win10 system setting computer never sleeps
- Fastjson parses JSON strings (deserialized to list, map)
- 中国白酒的5场大战
- Why is the cluster mode of spark on Yan better than the client mode
- Univariate cubic equation - relationship between root and coefficient
- Redistemplate common collection instructions opsforlist (III)
- JS method to stop foreach
- VIM basic configuration and frequently used commands
- Reset Mikrotik Routeros using netinstall
- MySQL - 事务(Transaction)详解
猜你喜欢

一行代码可以做些什么?

Yuan Xiaolin: safety is not only a standard, but also Volvo's unchanging belief and pursuit

Reset Mikrotik Routeros using netinstall

用aardio写一个旋转验证码标注小工具

Internet News: Geely officially acquired Meizu; Intensive insulin purchase was fully implemented in 31 provinces

jvm:大对象在老年代的分配

袁小林:安全不只是标准,更是沃尔沃不变的信仰和追求

跨分片方案 总结

Set up a time server

Method return value considerations
随机推荐
SQL:存储过程和触发器~笔记
The golden age of the U.S. technology industry has ended, and there have been constant lamentations about chip sales and 30000 layoffs
红杉中国,刚刚募资90亿美元
c语言char, wchar_t, char16_t, char32_t和字符集的关系
小满网络模型&http1-http2 &浏览器缓存
Sparkshuffle process and Mr shuffle process
跨分片方案 总结
What is the RDD operator in spark
JS method to stop foreach
麦趣尔砸了小众奶招牌
Sequoia China, just raised $9billion
Summary of cross partition scheme
Realization of epoll reactor model
First batch selected! Tencent security tianyufeng control has obtained the business security capability certification of the ICT Institute
NPM run dev start project error document is not defined
Start the embedded room: system startup with limited resources
ViT论文详解
强化学习-学习笔记5 | AlphaGo
One line by line explanation of the source code of anchor free series network yolox (a total of ten articles, you can change the network at will after reading it, if you won't complain to me)
用aardio写一个旋转验证码标注小工具