当前位置:网站首页>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
边栏推荐
- [Li Kou brush questions] 32 Longest valid bracket
- Z function (extended KMP)
- Method return value considerations
- 数字化转型挂帅复产复工,线上线下全融合重建商业逻辑
- 【MySQL】Online DDL详解
- The underlying implementation of string
- Yyds dry goods inventory C language recursive implementation of Hanoi Tower
- Redistemplate common collection instructions opsforlist (III)
- Dialogue with Jia Yangqing, vice president of Alibaba: pursuing a big model is not a bad thing
- PostgreSQL modifies the password of the database user
猜你喜欢
AI 企业多云存储架构实践 | 深势科技分享
Five wars of Chinese Baijiu
Numpy download and installation
PostgreSQL install GIS plug-in create extension PostGIS_ topology
1292_ Implementation analysis of vtask resume() and xtask resume fromisr() in freeros
互联网快讯:吉利正式收购魅族;胰岛素集采在31省全面落地
JS method to stop foreach
50 commonly used numpy function explanations, parameters and usage examples
It's not my boast. You haven't used this fairy idea plug-in!
数字化转型挂帅复产复工,线上线下全融合重建商业逻辑
随机推荐
bat脚本学习(一)
From campus to Tencent work for a year of those stumbles!
uni-app App端半屏连续扫码
guava: Multiset的使用
袁小林:安全不只是标准,更是沃尔沃不变的信仰和追求
Set up a time server
Is it important to build the SEO foundation of the new website
Redistemplate common collection instructions opsforhash (IV)
数字化转型挂帅复产复工,线上线下全融合重建商业逻辑
Shake Sound poussera l'application indépendante de plantation d'herbe "louable", les octets ne peuvent pas oublier le petit livre rouge?
Sql: stored procedures and triggers - Notes
[Yu Yue education] higher mathematics of Nanchang University (2) reference materials
基于InsightFace的高精度人脸识别,可直接对标虹软
R language for text mining Part4 text classification
关于char[]数组通过scanf赋值使用上的一些问题。。
string的底层实现
LeetCode:1189. The maximum number of "balloons" -- simple
PostgreSQL modifies the password of the database user
强化学习-学习笔记5 | AlphaGo
Absolute primes (C language)