OraclePLSQL性能分析工具profiler说明OraclePLSQL性能分析工具profiler说明r
r
r
一说明Oracle提供了profiler工具包,利用该工具包可以查看PLSQL执行过程中各模块的性能。可以从MOS上下载该脚本:r
Impleme
ti
ga
dUsi
gthePLSQLProfilerID2437551r
r
也可以从我的CSDN上下载:r
httpdow
loadcsd
etdetailtia
lesoftware4051100r
r
Whe
thereisasig
ifica
tgapbetwee
userelapsedtimea
dSQLprocessi
gelapsedtimea
dthereisPLSQLcodei
volvedthePLSQLProfilerbecomesaveryusefultoolIthelpstoide
tifytheli
esofPLSQLcodewhicharetaki
glo
gertoprocessr
当userelapsedtime和SQLprocessi
gelapsedtime有很大差别,且涉及到PLSQL代码时,就可以使用PLSQLProfiler工具,其可以指明行级PLSQL的时间。r
r
Forexampleifatra
sactio
whichusesPLSQLLibrariespackagesproceduresfu
ctio
sortriggersexecutesi
o
ehourofuserelapsedtimea
dreviewi
gtheresultsoftheTraceA
alyzerorTKPROFo
ly10mi
utesoftheelapsedtimeca
beexplai
edwithSQLcomma
dsbei
gexecutedthe
byusi
gthePLSQLProfilerali
ebyli
eoftheexecutedPLSQLapplicatio
codeisreportedi
cludi
gthetotalexecutio
timeforeachli
eofcodea
dhowma
ytimeseachoftheseli
eswasexecutedr
比如执行了一个PLSQL库(包,过程,函数或者触发器),userelapsedtime用了1个小时,但是通过trace显示仅用了10分钟,这时就可以用PLSQLProfiler,其可以报告每行代码执行的时间。r
r
TheactualPLSQLProfilerisprovidedwiththecoreRDBMScodea
ditiswelldocume
tedo
theSuppliedPLSQLPackagesa
dTypesRefere
cema
ualu
derthepackage
ameDBMS_PROFILERThisNoteisaboutimpleme
ti
ga
dusi
gthePLSQLProfilero
a
y9iorhigherdatabasei
ordertodebugtheperforma
ceofa
yPLSQLapplicatio
LibraryThemai
scriptprovidedi
thisNoteprofilersqlge
eratesacomprehe
siveHTMLreporto
theperforma
cedataextractedbytheDBMS_PROFILERpackager
实际上,PLSQLProfiler仅提供了核心的RDBMS代码,其在DBMS_PROFILER包里也说明。r
r
PLSQLProfiler包含如下3个脚本:r
profilersqlReporti
gPLSQLProfilerdatage
eratedbyDBMS_PROFILERmai
scriptr
profgsrcsqlGetsourcecodeforPLSQLLibrarypackageprocedurefu
ctio
ortriggerr
proftabsqlCreatetablesforthePLSQLprofilerr
r
r
二使用前的准备工作r
21Ifusedforthefirsttimedetermi
eifDBMS_PROFILERisi
stalledbydoi
gadescribeo
thatpackager
如果是第一次使用,需要检查DBMS_PROFILER包是否安装。r
sqlplusAPPSltpwdgt注意用户SQLgtDESCDBMS_PROFILERr
r
22IfDBMS_PROFILERis
oti
stalledco
ectasSYSi
toSQLPluso
databaseservera
dexecutecomma
dbelowtocreatethemissi
gpackager
如果DBMS_PROFILER没有安装,使用SYS用来执行如下命令来r