这篇文章给大家分享的是有关如何使用10046查看执行计划并读懂trace文件的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。查看 sql 执行计划的方法有活动:慈云数据爆款香港服务器,CTG+CN2高速带宽、快速稳定、平均延迟10+ms 速度快,免备案,每月仅需19元!! 点击查看许多种, 10046 事件就是其中的一种. 与其他查看 sql 执行计划不同, 当我们遇到比较复杂的 sql 语句, 我们可以通过 10046 跟踪 sql 得到执行计划中每一个步骤的逻辑读, 物理读以及花费的时间等. 这种细粒度的跟踪对于我们分析 sql 性能尤其有用.
一般来说, 使用 10046 事件得到 sql 执行计划的步骤如下:
1. 激活当前 session 10046 事件
2. 在当前 session 中执行 sql 语句
3. 关闭当前 session 10046 事件
执行完上述步骤后, 通常会自动生成一个 trace 文件. 在 oracle 11g 中, trace 文件一般放在$ORACLE_BASE/diag/rdbms/{database_name}/$ORACLE_SID/trace目录下. 如果使用 oradebug 激活跟踪 10046后, 可以使用 oradebug tracefile_name 得到刚刚生成的 trace 文件的完整路径.刚刚提到的 oradebug 激活跟踪 10046 事件, 我想大部分 dba 都会使用. oradebug 是个功能强大非常好用的工具, 使用 oradebug help 将会看到它的功能很多SQL> oradebug
helpHELP
[command]
Describe
one
or
all commandsSETMYPID Debug
current
processSETOSPID
Set
OS pid
of
process
to
debug
SETORAPID
[‘force’]
Set
Oracle
pid
of
process
to
debug
SETORAPNAME
Set
Oracle
process
name
to
debug
SHORT_STACK
Get
abridged OS stackCURRENT_SQL
Get
current
SQLDUM开发云主机域名P
[addr] Invoke named dump
DUMPSGA [bytes] Dump
fixed
SGADUMPLIST Print a
list
of
available dumpsEVENT
Set
trace
event
in
process
SESSION_EVENT
Set
trace
event
in
session
DUMPVAR
[level] Print/dump a
fixed
PGA/SGA/UGA
variable
DUMPTYPE SETVAR
Modify
a
fixed
PGA/SGA/UGA
variable
PEEK
[level] Print/Dump
memory
POKE
Modify
memory
WAKEUP
Wake up
Oracle
process
SUSPEND
Suspend
executionRESUME
Resume
executionFLUSH
Flush
pending writes
to
trace
fileCLOSE_TRACE
Close
trace
fileTRACEFILE_NAME
Get
name
of
trace
fileLKDEBUG Invoke
global
enqueue
service debuggerNSDBX Invoke CGS
name-service debugger-G
Parallel
oradebug command prefix
-R
Parallel
oradebug 开发云主机域名prefix (return
output
SETINST
Set
instance
list
in
double
quotes
SGAT开发云主机域名OFILE
Dump SGA
to
file; dirname in double quotes
DMPCOWSGA
Dump & map SGA as COW; dirname in double quotes
MAPCOWSGA
Map SGA as COW; dirname in double quotes
HANGANALYZE [level] [syslevel]
Analyze
system
hangFFBEGIN Flash Freeze the
InstanceFFDEREGISTER FF deregister
instance
from
clusterFFTERMINST
Call
exit
and
terminate
instanceFFRESUMEINST
Resume
the flash frozen
instanceFFSTATUS Flash freeze
status
of
instanceSKDSTTPCS
Helps
translate
PCs
to
names
WATCH DELETE
watchpoint
Delete
a watchpoint
SHOW
watchpoints Show
watchpoints
DIRECT_ACCESS
Fixed
table
access
CORE Dump core
without
crashing processIPC Dump ipc informationUNLIMIT Unlimit the
size
of
the
trace
filePROCSTAT Dump process
statisticsCALL
[arg1] … [argn] Invoke
function
with
arguments
感谢各位的阅读!关于“如何使用10046查看执行计划并读懂trace文件”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!
本文从转载,原作者保留一切权利,若侵权请联系删除。
《如何使用10046查看执行计划并读懂trace文件》来自互联网同行内容,若有侵权,请联系我们删除!
还没有评论,来说两句吧...