This document introduces Oracle session tracing by discussing how to assign a client identifier variable to sessions. It explains that assigning a client ID allows administrators to track individual sessions and their resource usage, even if they reuse the same session ID. It provides an example trigger that sets the client ID during logon based on the user and host name. It also shows how to query the V$SESSION view to see the client IDs and investigate wait times and resource consumption by client ID. Future articles will discuss setting the module and action names for more detailed tracing.
This document introduces Oracle session tracing by discussing how to assign a client identifier variable to sessions. It explains that assigning a client ID allows administrators to track individual sessions and their resource usage, even if they reuse the same session ID. It provides an example trigger that sets the client ID during logon based on the user and host name. It also shows how to query the V$SESSION view to see the client IDs and investigate wait times and resource consumption by client ID. Future articles will discuss setting the module and action names for more detailed tracing.
This document introduces Oracle session tracing by discussing how to assign a client identifier variable to sessions. It explains that assigning a client ID allows administrators to track individual sessions and their resource usage, even if they reuse the same session ID. It provides an example trigger that sets the client ID during logon based on the user and host name. It also shows how to query the V$SESSION view to see the client IDs and investigate wait times and resource consumption by client ID. Future articles will discuss setting the module and action names for more detailed tracing.
This is the first in a series to introdue some of the ne! train" onepts and options !ithin #ra$e. This insta$$ment fouses on the ne! C%&'(T)&*'(T&F&'+ en,ironment ,aria-$e that an -e assi"ned to sessions. The "oa$ of this series is to inform *./s on ho! to tra0 and trae onneted sessions so that the1 an proper$1 determine !here sessions are e2perienin" performane pro-$ems. This arti$e presents the ,er1 important onept of assi"nin" a $ient identifier to a session. This $ient identifier !i$$ -e used in future arti$es as this !i$$ -e one !a1 to initiate traes. This arti$e first presents the issue of !h1 !e shou$d use the $ient identifier and then ho! !e an uti$i3e it !hen $oo0in" at sessions as the1 are onneted in rea$ time. To -e"in4 !e must first ome to "rips !ith the simp$e onept of the "$o-a$i3ation of sessions !ithin #ra$e that ours. The da1s of sin"$e dediated ser,er onnetions and one onnetion uni5ue$1 identif1in" a sin"$e user are $on" "one. (o! man1 midd$e6tier app$iations ma0e use of poo$in" mehanisms that hide the identit1 of a onneted user or session that does not a$$o! 1ou or me to ade5uate$1 tra0 and trae effeti,e$1 -eause of the reuse of session ids. This is !here 1ou need to start thin0in" of definin" 1our o!n $ient identifier for the users that use 1our data-ase s1stems. This is 7ust !hat #ra$e no! has and throu"h the use of a $ient identifier a$$o!s for 1ou to either further se"re"ate or onso$idate sessions -1 assi"nin" an identifier that desri-es the onnetion for a partiu$ar user or set of users.. For e2amp$e4 suppose 1ou ha,e a de,e$opment en,ironment !here e,er1one $o"s in as a partiu$ar shema user and -eause of the onnetion mehanisms emp$o1ed4 users !i$$ reuse the same session id sometimes !hen the1 onnet. 8e$$4 if 1ou e,er !anted to trae these sessions to determine !ho !as onsumin" ,ast amounts of resoures or !as issuin" partiu$ar 9:%4 1ou !ou$d -e ,er1 hard pressed to run a trae and fi$ter for that user sine the hi"h ati,it1 !ou$d not "uarantee an1 one user !as on a partiu$ar session id. This is !here 1ou ou$d emp$o1 the use of a $ient identifier as #ra$e no! $ets us trae and trae reports on a uni5ue $ient identifier. To "et this "oin" a$$ 1ou need to do is in,o0e the *.;9)9'99&#(.9'T)&*'(T&F&'+ proedure !hen the session $o"s in. Fi"ure 1 "i,es a ,er1 simp$isti method throu"h a $o"on tri""er to set the $ient identifier. <ou an use an1thin" to distin"uish the session suh as &= address4 omputer / host name4 o/s user4 or a predefined app$iation name. & ha,e ta0en use of the *.;9)C#(T>T a$$s for user en,ironment information. Fi"ure 1 %o"on tri""er to set $ient)identifier CREATE OR REPLACE TRIGGER LOGON_TRIGGER AFTER LOGON ON DATABASE DECLARE v_user_identifier varchar2!"#$ BEGIN SELECT S%S_CONTE&T'(SEREN)'* 'OS_(SER'# ++','++ S%S_CONTE&T'(SEREN)'* 'IP_ADDRESS'# INTO v_user_identifier FRO- dua.$ DB-S_SESSION/SET_IDENTIFIERv_user_identifier#$ END$ 0 (o! !hen !e ta0e a $oo0 at the ?@9'99&#( ,ie!4 !e an see this C%&'(T)&*'(T&F&'+ set for ,arious sessions. %istin" 1 "i,es this t1pe of output. (o! if !e had the same data-ase user onnet throu"h some po$$in" mehanism4 if !e set our $ient identifier proper$14 !e ha,e the potentia$ to see a different $ient identifier. /$so if !e !ant to set the same $ient identifier for a "roup of users4 !e ou$d do that a$so. There are a$so methods of settin" the $ient identifier from !ithin #C& and J*.C. %istin" 1 ?@9'99&#( output 1 SELECT sid* c.ient_identifier* 2 service_na2e* acti3n* 23du.e 45 FRO- )6SESSION SID CLIENT_IDENTIFIER SER)ICE_NA-E ACTION -OD(LE 7777777777 77777777777777777777 7777777777777 777777777777 77777777777 1"8 9:33;2ann,12</=/=/1 :1=1 2s>r?42/e@e 1"! 9:33;2ann,12</=/=/1 :1=1 22c/e@e 1"< 9:33;2ann,12</=/=/1 :1=1 SAL5P.us 18! 9:33;2ann,12</=/=/1 :1=1 s.;.us/e@e 8e !i$$ "et to atua$$1 train" in a future arti$e -ut -asia$$1 the o$umns supp$ied in the 9:% se$et statement in %istin" 1 are a$$ a$$o!ed to fi$ter and onso$idate train" statistis on. Aopefu$$1 1ou an see that -1 settin" a $ient identifier !e ha,e 7ust added "reat po!er in determinin" the un0no!n users of our data-ase. 8e an no! throu"h e2tra train" options determine !ho and !hatBs ausin" pro-$ems in our data-ase. /$so note that -eause this fie$d an -e han"ed at !i$$4 there is nothin" to $imit 1ou to 0eepin" the same C%&'(T)&*'(T&F&'+ for the $ife of the session. This ma1 ome in hand1 if 1our session atua$$1 performs different tas0s that distin"uish it from other sessions that ori"ina$$1 had the same identifier. /fter settin" this $ient identifier4 !e ha,e a$read1 seen that 1ou ma1 ,ie! this settin" -1 the a 5uer1 to the ?@9'99&#( ,ie!. <ou ma1 an a$so see the statistis around a partiu$ar C%&'(T)&*'(T&F&'+ from the ?@/CT&?')9'99&#()A&9T#+< ,ie!. %istin" 2 "i,es a 5uer1 that !e !ou$d t1pia$$1 issue to see the historia$ !ait ati,it1 for sessions in the $ast C0 minutes. (otie that !e ha,e the same $ient identifier (C%&'(T)&*) for eah of the ro!s. This is fine if 1ou are onerned !ith on$1 tra0in" do!n one session that mi"ht -e e2perienin" hi"h !ait times -ut sometimes it is the aumu$ated !ait time that is aused -1 an app$iation 1ou are onerned a-out. To ans!er that 5uestion !e an "roup on the C%&'(T)&* o$umn no! and "et a summation for a partiu$ar $ient identifier. This does assume 1ou ha,e set 1our $ient identifier to somethin" more than !hat & ha,e set mine to and somethin" in $ine !ith the app$iation area of interest. %istin" C sho!s 7ust suh a 5uer1 1ou mi"ht issue to sum tota$ !aits for an app$iation area or in m1 ase user onnetion aross mu$tip$e sessions. %istin" 2 %oo0in" at indi,idua$ session !ait ati,it1 se.ect sessi3n_id* c.ient_id* event* su2Bait_ti2e C ti2e_Baited# tt._Bait_ti2e fr32 v6active_sessi3n_hist3r? active_sessi3n_hist3r? Bhere sa2;.e_ti2e DetBeen s?sdate 7 !=02EE= and s?sdate Fr3u; D? sessi3n_id* c.ient_id* event 3rder D? 2$ SESSION_ID CLIENT_ID E)ENT TTL_GAIT_TI-E 7777777777 77777777777777777777 777777777777777777777777777777 7777777777777 1"8 9:33;2ann,12</=/=/1 SAL5Net 2essaFe t3 c.ient 4 1"8 9:33;2ann,12</=/=/1 dD fi.e scattered read 1111!< 1"8 9:33;2ann,12</=/=/1 dD fi.e se>uentia. read 8H==4 1"8 9:33;2ann,12</=/=/1 direct ;ath read te2; H441" 1"8 9:33;2ann,12</=/=/1 direct ;ath Brite te2; 2 18! 9:33;2ann,12</=/=/1 SAL5Net 2essaFe fr32 c.ient 2"41H2!E1 1!= 9:33;2ann,12</=/=/1 dD fi.e scattered read 1E!8< 1!= 9:33;2ann,12</=/=/1 dD fi.e se>uentia. read 2E1"1 1!= 9:33;2ann,12</=/=/1 direct ;ath read te2; "EE< 1!= 9:33;2ann,12</=/=/1 direct ;ath Brite te2; 2" %istin" C /umu$ated !ait ati,it1 for an app$iation area or user defined area se.ect c.ient_id* event* su2Bait_ti2e C ti2e_Baited# tt._Bait_ti2e fr32 v6active_sessi3n_hist3r? active_sessi3n_hist3r? Bhere sa2;.e_ti2e DetBeen s?sdate 7 !=02EE= and s?sdate Fr3u; D? c.ient_id* event 3rder D? 1$ CLIENT_ID E)ENT TTL_GAIT_TI-E 77777777777777777777 777777777777777777777777777777 7777777777777 9:33;2ann,12</=/=/1 SAL5Net 2essaFe fr32 c.ient 2"41H2!E1 9:33;2ann,12</=/=/1 SAL5Net 2essaFe t3 c.ient 4 9:33;2ann,12</=/=/1 dD fi.e scattered read 12HE2" 9:33;2ann,12</=/=/1 dD fi.e se>uentia. read 118884 9:33;2ann,12</=/=/1 direct ;ath read te2; HE2=1 9:33;2ann,12</=/=/1 direct ;ath Brite te2; 2! /$so if 1ou e,er find 1ourse$f !antin" to 0no! !hat 1our C%&'(T)&*'(T&F&'+ is set to so that 1ou an monitor or ta0e some for of $o"ia$ ation !ithin an app$iation4 1ou need on$1 issue the fo$$o!in" 9:%. SELECT S%S_CONTE&T'(SEREN)'*'CLIENT_IDENTIFIER'# CLIENT_IDENTIFIER FRO- D(AL$ CLIENT_IDENTIFIER 7777777777777777777 9:33;2ann,12</=/=/1 &f 1ou e,er !ish to $ear out the C%&'(T)&*'(T&F&'+ for a session4 1ou need on$1 e2eute the fo$$o!in" proedure. *.;9)9'99&#(.C%'/+)&*'(T&F&'+ The use of a C%&'(T)&*'(T&F&'+ an ome in hand1 for man1 situations !here monitorin" indi,idua$ sessions or a "roup of sessions is re5uired. &t does not matter if those sessions onnet to the same session id or different ones. &f 1ou hoose 1our $ient identifier proper$1 for "roups of app$iations or users4 1ou an no! "enerate true !ait re$ated information that te$$s 1ou e2at$1 !hat the1 ha,e -een doin". 9ta1 tuned for more session train" in the ne2t part of this series. Oracle Session Tracing Part II James F. Koopmann posted 5/2D/2007 | Comments (1) +ead on and $earn ho! to set the modu$e and ation names. &n =art & of this 9ession Train" 9eries !e $earned ho! to set the C%&'(T)&*'(T&F&'+ session ,aria-$e and ho! !e ou$d 5uer1 it from the ?@9'99&#( ,ie!. 8e a$so $oo0ed at ho! to $oo0 at the resoures onsumed in rea$6time for that C%&'(T)&*'(T&F'+ so that !e ou$d determine if $ar"e amounts of resoures !ere attri-uted to a uni5ue or "roup of $ient onnetions. &f 1ou remem-er from =art &4 !e in,o0ed a $o"on tri""er !hene,er a session onneted and then 5ueried the ?@9'99&#( ,ie!. This "a,e us output simi$ar to that of %istin" 1. From this output 1ou an see a C%&'(T)&*'(T&F&'+ that is -ein" set4 & han"ed the $o"on tri""er to put in host name instead of &= address in this e2amp$e4 and 1ou an see that the modu$e name did "et popu$ated for the app$iations & used to onnet from (9:%E=$us and #ra$e /dministrati,e /ssistant). /$so note that the ation fie$d is -$an0. /$so notie that the there are t!o onnetions usin" 9:%E=$us from host F&('6/%' and one onnetion from host =/F%/('+. %istin" 1 ?@9'99&#( output SALI SELECT sid* c.ient_identifier* acti3n* 23du.e FRO- )6SESSION SID CLIENT_IDENTIFIER ACTION -OD(LE 7777 77777777777777777777777777777777777777777 77777777777777777777 777777777777777777 144 Ja2esKF/KL33;2ann,PINEMORSENFINE7ALE SAL5P.us 148 Ja2esKF/KL33;2ann,PINEMORSENFINE7ALE 22c/e@e 1"H Ja2esKF/KL33;2ann,PINEMORSENFINE7ALE SAL5P.us 142 PA(LANERNAd2inistrat3r,PINEMORSENPA(LANER SAL5P.us The settin" of the C%&'(T)&*'(T&F&'+ !as of "reat importane -ut if !e !ant to "et finer "ranu$arit1 on the atua$ amount of resoures that are -ein" onsumed !ithin ertain modu$es of ode or !ithin ertain -usiness units of !or0 !e need to no! $oo0 at the *.;9)/==%&C/T&#()&(F# pa0a"e pro,ided -1 #ra$e. ;ost app$iations !i$$ "i,e some form of modu$e name !hen 1ou see onnetions omin" aross -ut !i$$ $ea,e the /CT&#( name unset. The settin" of a modu$e name is fine for some irumstanes -ut to "et a rea$ indiation of !here in the ode resoures are -ein" done -oth fie$ds shou$d -e onsidered !hen !ritin" app$iations. This namin" !i$$ a$$o! 1ou as a *./ or de,e$oper the a-i$it1 to tra0 do!n uni5ue onnetions that 1ou are onerned !ith in rea$6time or for $atter train" runs. This "ranu$arit1 is hi"h$1 desired !hen de-u""in" a performane -ott$ene0 and 1ou !i$$ !ant to pin point !hat app$iation modu$e is onsumin" the most resoures throu"h the ;#*F%' name and !hat is -ein" done (/CT&#() !ithin the ode. To do this4 it is imperati,e4 that the app$iations set the name of the modu$e and the ation -ein" performed eah and e,er1 time it enters a ne! modu$e or the ation of the transation han"es. The modu$e name ou$d -e the setion of ode or proedure -ein" e2euted4 !hi$e the ation ou$d -e a -usiness unit of !or0 or an indi,idua$ statement. The purpose is to -e a-$e to tie resoures used to a unit of !or0 that 1ou are onerned a-out. Ca$$in" the *.;9)/==%&C/T&#()&(F# =a0a"e Fsin" the *.;9)/==%&C/T&#()&(F# pa0a"e is 5uite simp$isti. / simp$e a$$ to 9'T)/CT&#( is a$$ that is re5uired to set the /CT&#( name. This a$$ has the form ofG DB-S_APPLICATION_INFO/SET_ACTION acti3n_na2e IN )ARCMAR2#$ 9o if 1ou !anted to set the /CT&#( to B%#H#( T+&HH'+B 1ou ou$d onstrut the a$$ asG DB-S_APPLICATION_INFO/SET_ACTION'LOGON TRIGGER'#$ This ation name shou$d -e ,er1 desripti,e of the t1pe of ation -ein" done !ithin the ode and is a$!a1s -est to set this -efore the atua$ ation is performed. That !a1 !hen the ation is -ein" performed 1ou !i$$ see the /CT&#( in the ?@9'99&#( ,ie! and 0no! that it is urrent$1 -ein" done. 8hen the transation or speifi ation is omp$ete !ithin 1our ode 1ou shou$d set it -a0 to (F%% or to the ne2t ation to -e performed. This settin" of to (F%% or a ,a$id ne2t transation t1pe is ,er1 important. &f 1ou do not adhere to this pattern4 future resoures !i$$ -e attri-uted to the $ast /CT&#( and 1ou !i$$ $ose an1 true performane statistis. The settin" of the ;#*F%' name is done throu"h a a$$ to the 9'T);#*F%' proedure and has the form ofG DB-S_APPLICATION_INFO/SET_-OD(LE 23du.e_na2e IN )ARCMAR2* acti3n_na2e IN )ARCMAR2#$ /$$ of the su""estions around settin" the /CT&#( app$1 to the settin" the ;#*F%' name as !e$$. 8hen settin" this namin" fie$d4 1ou !ant to set it -efore the atua$ e2eution !ithin the ode is started and 1ou !ant to ma0e sure to set the ;#*F%' -a0 to (F%% or to the ne2t ;#*F%' to -e e2euted so as to not miss6represent an1 statistis enountered after the true e2eution of the ode is omp$ete. /s 1ou mi"ht ha,e reo"ni3ed4 this 9'T);#*F%' proedure a$$o!s for the settin" of the /CT&#( name a$so. <ou shou$d use this to set 1our ;#*F%' and /CT&#( name !hen first enterin" a ne! modu$e of ode -ut use the 9'T)/CT&#( proedure after in the modu$e. This !i$$ $imit some of the o,erhead of settin" these names as & am sure there are some minisu$e $o0in" "oin" on -ehind the senes. 9o for our $o"on tri""er if & !anted to no! set the atua$ ;#*F%' and /CT&#( names it !ou$d $oo0 $i0e that of Fi"ure 1. <ou shou$d note that this is 5uite an e2treme e2amp$e of settin" these session ,aria-$es -ut rea$$1 7ust !anted to "i,e a f$a,or for ho! to do this. (otie that the ;#*F%' name !as set to B%#H#()T+&HH'+B and the /CT&#( is to indiate a 9'%'CT from *F/%. /$so note that at the end of the tri""er !e set the ;#*F%' and /CT&#( -a0 to (F%% so that !e are ertain not to mess up statistia$ o$$etion. /$so p$ease note that & ha,e put in a a$$ to the *.;9)%#CK pa0a"e to s$eep so that & ou$d see this settin" of the ;#*F%' and /CT&#( names. Fi"ure 1 %o"on tri""er to set $ient)identifier4 modu$e4 and ation CREATE OR REPLACE TRIGGER LOGON_TRIGGER AFTER LOGON ON DATABASE DECLARE v_user_identifier varchar2!"#$ BEGIN DB-S_APPLICATION_INFO/SET_-OD(LE 23du.e_na2e OI 'LOGON_TRIGGER'* acti3n_na2e OI 'SELECT FRO- D(AL'#$ SELECT S%S_CONTE&T'(SEREN)'* 'OS_(SER'# ++','++ S%S_CONTE&T'(SEREN)'* 'MOST'# INTO v_user_identifier FRO- dua.$ DB-S_SESSION/SET_IDENTIFIERv_user_identifier#$ dD2s_.3c:/s.ee;8#$ DB-S_APPLICATION_INFO/SET_-OD(LEN(LL*N(LL#$ END$ 0 (o! !hen !e 5uer1 the ?@9'99&#( ,ie! !e an see the settin" of these ,aria-$es throu"h %istin" 2. /fter the *.;9)%#CK.9%''= a$$ is omp$ete the ;#*F%' name returns to B9:%E=$usB and the /CT&#( is (F%%. & am thin0in" this is a funtion of 7ust usin" 9:%E=$us and 1ou shou$d not re$1 on #ra$e settin" these -a0 to the ori"ina$ a$$. %istin" 2 ?@9'99&#( output after settin" ;#*F%' and /CT&#( names SALI SELECT sid* c.ient_identifier* acti3n* 23du.e FRO- )6SESSION SID CLIENT_IDENTIFIER ACTION -OD(LE 7777 77777777777777777777777777777777777777777 77777777777777777777 777777777777777777 144 Ja2esKF/KL33;2ann,PINEMORSENFINE7ALE SELECT FRO- D(AL LOGON_TRIGGER 148 Ja2esKF/KL33;2ann,PINEMORSENFINE7ALE 22c/e@e 1"H Ja2esKF/KL33;2ann,PINEMORSENFINE7ALE SAL5P.us 142 PA(LANERNAd2inistrat3r,PINEMORSENPA(LANER SAL5P.us =roper settin" of the /CT&#( and ;#*F%' name are imperati,e for o$$etin" statistis around speifi ode funtions and transations. #ne the1 are set 1ou an no! -e"in "ettin" those fine "rain detai$s a-out the area of ode that is performin" poor$1. (e2t time !e start $oo0in" at ho! to atua$$1 pu$$ out of urrent sessions that fine "rain information to 3ero in on !here !e need to onentrate our tunin" efforts. Oracle Session Tracing Part III James F. Koopmann posted D/1/2007 | Comments (1) '2p$ore ho! to ena-$e and disa-$e #ra$e train" !ith *.;9);#(&T#+ pa0a"e in 10". &n =art & !e $earned ho! to set the C%&'(T)&*'(T&F&'+ session ,aria-$e to more aurate$1 pinpoint resoure onsumption for an indi,idua$ user or "roup of users. 8e did this throu"h 5ueries to rea$6time ati,it1 ,ie!s suh as ?@9'99&#( and ?@/CT&?')9'99&#()A&9T#+<. &n =art && !e $earned ho! to set the /CT&#( and ;#*F%' name so that !e ou$d tra0 !here in our ode transations !here -ein" e2euted and tra0 the use of resoures -1 transation t1pe or setion of ode. /$on" !ith these possi-$1 ne! session identifiers4 there has a$!a1s -een three session en,ironment ,aria-$es that "et set from !hen a user onnets to the data-ase and are important !hen ta$0in" a-out train" a partiu$ar session or "roup of sessions. These !ou$d -e the 9&*4 9'+&/%I4 and 9'+?&C')(/;'. These ha,e -een around #ra$e sessions for 5uite some time -ut are presented in Ta-$e 1 !ith the three ne! ,aria-$es presented in =arts & J && of this series to pro,ide for a 5ui0 refresher. This set of si2 session ,aria-$es no! "i,es us the a-i$it1 to ati,ate train" for the session in a ,ariet1 of !a1s. Table 1 Sessi3n )ariaD.e Descri;ti3n SID Identifier f3r the c3nnected sessi3n/ SERIALP Seria. nu2Der 3f the c3nnected/ SER)ICE_NA-E Service na2e 3f the sessi3n and re;resents the dataDase c3nnected t3/ -OD(LE Na2e t3 re;resent the 23du.e 3r c3de DeinF e@ecuted/ ACTION Na2e t3 re;resent the acti3n DeinF ;erf3r2ed D? the 23du.e/ CLIENT_IDENTIFIER Identifier t3 re;resent the c.ient sessi3n DBMS_MONITOR Package &n #ra$e 10"4 !e ha,e -een "i,en the *.;9);#(&T#+ pa0a"e. This pa0a"e a$$o!s us to interat and ontro$ the train" and statistis "atherin" of sessions throu"h a =%/9:% interfae. Ta-$e 2 "i,es a$$ of the pro"rams !e an a$$ throu"h the *.;9);#(&T#+ pa0a"e. /s 1ou an see4 a$$ our si2 ,aria-$es are represented for us to -e"in train" throu"h. Ta-$e C "i,es a 5ui0 referene "uide on the a,ai$a-$e pro"rams !ithin the *.;9);#(&T#+ pa0a"e and ho! 1ou mi"ht ena-$e these traes. Table 2 =ro"ram *esription (otes C%&'(T)&*)9T/T)'(/.%' C%&'(T)&*)9T/T)*&9/.%' 'na-$e / *isa-$e 9tatistis "atherin" for / "i,en C$ient &dentifier 9tatistis an -e seen throu"h ?@C%&'(T)9T/T9. C%&'(T)&*)T+/C')'(/.%' C%&'(T)&*)T+/C')*&9/.%' 'na-$e / *isa-$e Train" for / "i,en C$ient &dentifier Trae data ma1 -e !ritten to man1 trae fi$es as the trae ma1 effet mu$tip$e onneted sessions !ith the same $ient identifier. 9'+?);#*)/CT)9T/T)'(/.%' 9'+?);#*)/CT)9T/T)*&9/.%' 'na-$e / *isa-$e 9tatistis "atherin" for (9er,ie (ame/;#*F%'//CT&# () om-ination. 9tatistis an -e seen throu"h ?@9'+?);#*)/CT)9T/T 9. 9'+?);#*)/CT)T+/C')'(/.% ' 9'+?);#*)/CT)T+/C')*&9/. %' 'na-$e / *isa-$e Train" for (9er,ie (ame/;#*F%'//CT&# () om-ination. Trae data ma1 -e !ritten to man1 trae fi$es as the trae ma1 effet mu$tip$e onneted sessions. 9'99&#()T+/C')'(/.%' 9'99&#()T+/C')'&9/.%' 'na-$e / *isa-$e Train" for a session identifier (9&*) 9ession must e2ist Traes on$1 a "i,en session 'na-$es / *isa-$es a trae for the instane su-mitter is onneted to. Table 3 =ro"ram '2amp$e Ao! to 'na-$e C%&'(T)&*)9T/T)'(/.%' C%&'(T)&*)9T/T)*&9/.%' *.;9);#(&T#+.C%&'(T)&*)9T/T)'(/.%' ($ient)identifier)K C%&'(T)&*)T+/C')'(/.%' C%&'(T)&*)T+/C')*&9/.%' *.;9);#(&T#+.C%&'(T)&*)T+/C')'(/.%' ($ient)id4 !aits4 -inds)K ((otes) !aits G &f T+F'4 !ait information is present in the trae. .inds G &f T+F'4 -ind information is present in the trae. 9'+?);#*)/CT)9T/T)'(/.%' 9'+?);#*)/CT)9T/T)*&9/.%' *.;9);#(&T#+.9'+?);#*)/CT)9T/T)'(/.% ' (ser,ie)name4 modu$e)name4 ation)name)K ((otes) /tion)name4 ma1 -e an empt1 fie$d if not defined for the session. To referene /%% sessions that ha,e an ation)name defined4 use the *.;9);#(&T#+./%%)/CT&#(9 ,aria-$e. To referene /%% sessions that do not ha,e this ,aria-$e defined4 use (F%%. The ontents of this fie$d is atua$$1 BIII/%%)/CT&#(9B and 1ou shou$d a,oid namin" an1 ations or modu$e names !ith this. 9'+?);#*)/CT)T+/C')'(/.% ' 9'+?);#*)/CT)T+/C')*&9/. %' *.;9);#(&T#+.9'+?);#*)/CT)T+/C')'(/. %' (ser,ie)name4 modu$e)name4 ation)name4 !aits4 -inds4 instane)name)K ((otes) /tion)name4 ma1 -e an empt1 fie$d if not defined for the session. To referene /%% sessions that ha,e an ation)name defined4 use the *.;9);#(&T#+./%%)/CT&#(9 ,aria-$e. To referene /%% sessions that do not ha,e this ,aria-$e defined4 use (F%%. The ontents of this fie$d is atua$$1 BIII/%%)/CT&#(9B and 1ou shou$d a,oid namin" an1 ations or modu$e names !ith this. !aits G &f T+F'4 !ait information is present in the trae. .inds G &f T+F'4 -ind information is present in the trae. instane)name restrits train" to the named instane)name. 9'99&#()T+/C')'(/.%' 9'99&#()T+/C')*&9/.%' *.;9);#(&T#+.9'99&#()T+/C')'(/.%' (session)id4 seria$)num-er4 !aits4 -inds) ((otes) session)id4 ;ust pro,ide. &f 7ust a session)id is "i,en than a$$ seria$ num-ers !i$$ -e traed. &f session)id and seria$)num-er are (F%% than 1ou trae 1our o!n urrent session. !aits G &f T+F'4 !ait information is present in the trae. .inds G &f T+F'4 -ind information is present in the trae. Examples to Enable Disable Tracing .efore 1ou an ena-$e or disa-$e train" 1ou need to first determine the onneted session or "roup of sessions 1ou !ou$d $i0e to trae. &f 1ou ha,e set the C%&'(T)&*'(T&F&'+4 ;#*F%')(/;'4 or /CT&#()(/;' as presri-ed in the pre,ious parts to this series 1ou do not neessari$1 need to $oo0 for them as 1ou shou$d ha,e a $ist that desri-es their ations. /$thou"h sometimes 1ou are tunin" in a more adho en,ironment !here 1ou are on$1 onerned !ith !hat is effetin" 1our s1stem urrent$1. This ou$d -e an indi,idua$ session or a "roup of sessions !hih !i$$ -e defined -1 their C%&'(T)&*'(T&F&'+4 ;#*F%')(/;'4 /CT&#()(/;'4 or 9'+?&C')(/;'. To "et a fee$ for !hat is e2eutin" urrent$1 on 1our s1stem 1ou need on$1 5uer1 the ?@9'99&#( ,ie!. %istin" 1 "i,es the 9:% and resu$ts of !hat 1ou mi"ht see. Listing 1 1 SELECT sid* seria.P* c.ient_identifier* service_na2e* acti3n* 23du.e FRO- )6SESSION SID SERIALP CLIENT_IDENTIFIER SER)ICE_NA-E ACTION -OD(LE 7777777777 7777777 77777777777777777777 7777777777777 777777777777 77777777777 1"8 4" Fe3rFe,12</=/=/1 ACCT INSERT -ONTM PA%ROLL 1"! 42 93hnn?,12</=/=/2 ACCT CANCEL CMECL BILLPA% 1"< 8" suQ?,12</=/=/4 MR -OD)ACATION 18! !" .isa,12</=/=/" MR INSERT MIST ADDE-PLO%EE 1/ EnaD.e statistics FatherinF f3r CLIENT_IDENTIFIER BeDc.ient/ E&EC(TE DB-S_-ONITOR/CLIENT_ID_STAT_ENABLE'GEBCLIENT'#$ 2/ EnaD.e tracinF f3r CLIENT_IDENTIFIER 93hnn?,12</=/=/2 Bith Bait inf3r2ati3n Dut n3 Dind inf3r2ati3n E&EC(TE DB-S_-ONITOR/CLIENT_ID_TRACE_ENABLE'93hnn?,12<,=/=/2'*TR(E*FALSE#$ 4/ EnaD.e statistics FatherinF f3r service_na2e ACCT* 23du.e PA%ROLL* and a.. acti3ns E&EC(TE DB-S_-ONITOR/SER)_-OD_ACT_STAT_ENABLE'ACCT'*'PA%ROLL'*DB-S_-ONITOR/ALL_ACTIO NS#$ "/ EnaD.e tracinF f3r servide_na2e MR Dut 3n.? f3r the ADDE-PLO%EE 23du.e and inc.ude Bait and Dind inf3r2ati3n/ E&EC(TE DB-S_-ONITOR/SER)_-OD_ACT_TRACE_ENABLE'MR'*'ADDE-PLO%EE'* DB-S_-ONITOR/ALL_ACTIONS*TR(E*TR(E*N(LL#$ 8/ EnaD.e tracinF f3r sessi3n id 1"2 and inc.ude Bait and Dind inf3r2ati3n E&EC(TE DB-S_-ONITOR/SESSION_TRACE_ENABLE1"8*4"* TR(E* TR(E#$ !/ Trace 2? current sessi3n E&EC(TE DB-S_-ONITOR/SESSION_TRACE_ENABLEN(LL*N(LL* TR(E* TR(E#$ !ie" #o$r Enable% Tracing To ta0e a $oo0 at !hat 1ou ha,e ena-$ed train" and statistis "atherin" for 1ou need on$1 ta0e a $oo0 at the t!o ,ie!s *./)'(/.%'*)T+/C'9 and *./)'(/.%'*)/HH+'H/T&#(9. %istin" 2 "i,es the output from se$etin" from these t!o ,ie!s for our e2amp$es. (otie that the e2amp$es 5 J D !here !e started a trae for the sessions did not sho! up in %istin" 2. These must sti$$ -e reo"ni3ed -1 "oin" to the user dump $oation on dis0 and $oo0in" for the trae fi$es "enerated. &isting 2 SALI se.ect 5 fr32 DBA_ENABLED_TRACES $ TRACE_T%PE SER)ICE -OD(LE ACTION GAITS BINDS INSTANCE_NA-E 777777777777777777777 77777777777777777777 7777777777777 7777777777 77777 77777 7777777777777777 CLIENT_ID 93hnn?,12<,=/=/2 TR(E FALSE SER)ICE_-OD(LE MR ADDE-PLO%EE TR(E TR(E SALI SELECT 5 FRO- DBA_ENABLED_AGGREGATIONS $ AGGREGATION SER)ICE -OD(LE ACTION 77777777777777777777 77777777777777777777 77777777777777777777 77777777777777777777 CLIENT_ID BeDc.ient SER)ICE_-OD(LE ACCT PA%ROLL 'na-$in" and disa-$in" train" and statistia$ "atherin" has ta0en on a !ho$e ne! meanin" in #ra$e 10". &t has -eome easier to ena-$e and mana"e !ith the *.;9);#(&T#+ pa0a"e. 8e are not strapped -1 the o$d methods of train" !here !e ou$d 7ust trae an indi,idua$ session -ut an no! trae aross sessions -1 usin" the C%&'(T)&*'(T&F&'+4 9'+?&C')(/;'4 ;#*F%')(/;'4 and /CT&#()(/;'. (e2t time !e !i$$ $oo0 at !here some of the atua$ train" information resides and ho! to 5uer1 from interna$ ta-$es in #ra$e. Oracle Session Tracing Part I! James F. Koopmann posted D/8/2007 | Comments (0) &n =art &&& !e $eft off disp$a1in" the ena-$ed traes and statisti "atherin"s !e ena-$ed throu"h the *.;9);#(&T#+ pa0a"e.+ea$$ that in =art &&& !e 5ueried the *./)'(/.%'*)/HH+'H/T&#(9 ,ie! and had a $istin" suh as in %istin" 1. Ta-$e 1 "i,es a -rea0do!n of the *./)'(/.%'*)/HH+'H/T&#(9 ,ie! as & ha,e renamed some of the o$umns for %istin" 1. %istin" 1 DBA_ENABLED_AGGREGATIONS SALI SELECT 5 FRO- DBA_ENABLED_AGGREGATIONS $ AGGREGATION SER)ICE -OD(LE ACTION 77777777777777777777 77777777777777777777 77777777777777777777 77777777777777777777 CLIENT_ID BeDc.ient SER)ICE_-OD(LE ACCT PA%ROLL Ta-$e 1 *./)'(/.%'*)/HH+'H/T&#(9 Co$umn *esription /HH+'H/T&#()T<=' This is the t1pe of statistia$ a""re"ation -ein" done. This re$ates to the atua$ proedure a$$ed in the *.;9);#(&T#+ pa0a"e. &n %istin" 1 & !e ha,e a$$ed the C%&'(T)&*)9T/T)'(/.%' and 9'+?);#*)/CT)9T/T)'(/.%' proedures =+&;/+<)&* This is the C%&'(T)&*'(T&F&'+ or 9'+?&C')(/;' in the a$$ :F/%&F&'+)&*1 The modu$e name :F/%&F&'+)&*2 The ation name &n the $ast three parts of this series !e ha,e a$so 3eroed in on settin" different session en,ironment ,aria-$es. Those ,aria-$es !ere C%&'(T)&*'(T&F&'+4 /CT&#(4 and ;#*F%'. 8e ha,e a$so tra0ed some of the sessions -1 9&*4 9'99&#()&*4 9'+?&C')(/;'4 and 9'+&/%I. & thou"ht it mi"ht -e interestin" to ta0e a $oo0 at !here !ithin #ra$eBs interna$ ,ie!s these o$umns mi"ht -e defined as this ou$d he$p us in our future needs of in,esti"ation. &nstead of searhin" throu"h the end$ess doumentation of #ra$e4 & instead deided to produe a 5uer1 (%istin" 2) in !hih & 5ueried the *./)T/.)C#%F;(9 ,ie! to ta0e a $oo0 at !hat interna$ #ra$e ,ie!s or o-7ets ha,e these o$umns in ommon. & an then from the output ta0e a $oo0 at the definitions of those named o-7ets that intri"ue me. %istin" 2 is on$1 a partia$ $istin" and & enoura"e 1ou to e2eute the 5uer1 and see the tota$ output. That !a1 if 1ou are e,er interested in searhin" for a sin"e o$umn or om-ination of o$umns 1ou !i$$ 0no! !here !ithin the #ra$e interna$ ,ie!s this information is stored. *o not ta0e this output too $i"ht$1. &f 1ou remem-er that !e !ere ena-$in" statistis "atherin" and train" in the pre,ious parts to this arti$e for om-inations of these o$umns4 1ou an 5ui0$1 see !here in this $istin" the information is 0ept and !here a""re"ates on o$umns are stored. .e a$so !arned that most of the output 1ou !i$$ see are for #ra$eBs !or0$oad repositor14 ad,isories4 and snapshots mehanisms and are not of an1 rea$ use un$ess 1ou are usin" those uti$ities. For us & ha,e on$1 $eft the o-7ets !e !i$$ -e onerned !ith for $oo0in" at the "athered statistis !e ha,e ena-$ed. Ta-$e 2 "i,es a -rief e2p$anation of these ,ie!s4 ho! 1ou mi"ht use them4 and some thin"s to $oo0 out for. %istin" 2 :uer1 to in,esti"ate #ra$e ?ie!s that ontain our statistia$ information se.ect taD.e_na2e *su2dec3dec3.u2n_na2e*'SID'*1*'SESSION_ID'*1*=## SID *su2dec3dec3.u2n_na2e*'CLIENT_ID'*1*'CLIENT_IDENTIFIER'*1*=## CLIENT_ID *su2dec3dec3.u2n_na2e*'SER)ICE_NA-E'*1*=## SER)ICE_NA-E *su2dec3dec3.u2n_na2e*'ACTION'*1*=## ACTION *su2dec3dec3.u2n_na2e*'-OD(LE'*1*=## -OD(LE *su2dec3dec3.u2n_na2e*'SERIALP'*1*=## SERIALP fr32 se.ect 3Bner*taD.e_na2e*c3.u2n_na2e fr32 dDa_taD_c3.u2ns Bhere 3Bner O 'S%S' and c3.u2n_na2e in 'SID'* 'SESSION_ID'* 'CLIENT_ID'* 'CLIENT_IDENTIFIER'* 'SER)ICE_NA-E'* 'ACTION'* '-OD(LE'* 'SERIALP'## Fr3u; D? taD.e_na2e 3rder D? taD.e_na2e 0 CLIENT SER)ICE TABLE_NA-E SID ID NA-E ACTION -OD(LE SERIALP 777777777777777777777777777777 777 777777 7777777 777777 777777 7777777 DBA_MIST_ACTI)E_SESS_MISTOR% 1 1 = 1 1 = )_6ACTI)E_SESSION_MISTOR% 1 1 = 1 1 = )_6CLIENT_STATS = 1 = = = = )_6SER)ICE_STATS = = 1 = = = )_6SER)_-OD_ACT_STATS = = 1 1 1 = Ta-$e 2 Ta-$e *esription ?)@/CT&?')9'99&#()A&9T#+< The ?@/CT&?')9'99&#()A&9T#+< ,ie! is a ho$din" area for samp$ed session data performed on 1our -eha$f from the #ra$e en"ine. This data is samp$ed one per seond and is a "reat resoure for determinin" !here the true -ott$ene0 $ies in 1our s1stem. Fse this ,ie! in on7untion !ith settin" the C%&'(T)&*'(T&F&'+4 /CT&#(4 and ;#*F%' to a""re"ate (H+#F= .<) and find the $ar"est onsumers of resoures !ithin 1our s1stem. *./)A&9T)/CT&?')9'99)A&9T#+< This ,ie! is 7ust a historia$ representation of the ?@/CT&?')9'99&#()A&9T#+< ,ie! a-o,e. 8hi$e it is "ood for some historia$ information4 -e !arned that it does not ontain a$$ the o$$eted statistis that !ere aptured in the ?@/CT&?')9'99&#()A&9T#+< ,ie!. =$ease read the a-o,e mentioned arti$e to "et an understandin" ho! this !or0s. ?)@C%&'(T)9T/T9 &f 1ou ha,e ena-$ed an1 statistis for a C%&'(T)&*'(T&F&'+ 1ou !i$$ see the a""re"ated statistis for that C%&'(T)&*'(T&F&'+ in this ,ie! that are urrent$1 ati,e. statistis are on$1 "ood for urrent ati,it1 and trou-$eshootin" and thus shou$d on$1 -e used for "ettin" a "$impse of !hat $ients are onsumin" the most resoures. ?er1 ,a$ua-$e for a 5ui0 urrent ,ie! -ut if 1ou need to dri$$ to a partiu$ar $ient 1ou !i$$ end up "oin" to ?@/CT&?')9'99&#()A&9T#+<. ?)@9'+?&C')9T/T9 =ro,ides a redued set of statistis that an -e used to determine ho! !e$$ an instane is performin" for the re5uests made upon it. is t1pia$$1 the 9&*)(/;' -ut -e!are it ma1 -e different if 1ou are not onnetin" throu"h T(9. ?)@9'+?);#*)/CT)9T/T9 This ,ie! pro,ides an a""re"ated ,ie! for the om-ination of 9'+?&C')(/;'4 ;#*F%'4 and /CT&#( 1ou ha,e defined !hen 1ou ena-$ed a""re"ated statistis. Just -e arefu$ to name these a""re"ates appropriate$1 so that 1ou an 5ui0$1 determine !here -ott$ene0s reside. The use of these ,ie!s is 5uite strai"ht for!ard. <ou need on$1 5uer1 them for the statistia$ a""re"ation 1ou ha,e set up throu"h the *.;9);#(&T#+ pa0a"e. The rea$ diffiu$t1 $ies in settin" up those a""re"ations stepped throu"h in ear$ier =arts of this series. (e2t time !e !i$$ "et into the ne! reportin" options a,ai$a-$e for traes in #ra$e 10". Oracle Session Tracing Part ! James F. Koopmann posted D/15/2007 | Comments (1) =art ? in our series !i$$ "et $oser to !hat !e ha,e for 1ears e2periened as #ra$eBs train" mehanism. +ead #n and "et re6a5uainted !ith reatin" trae fi$es for TK=+#F. For man1 1ears *./s ha,e -een "ettin" $o! $e,e$ train" information a-out session throu"h the reatin" and readin" of #ra$e "enerated trae fi$es. These trae fi$es an -e "enerated a"ainst a fu$$ s1stem $oad or indi,idua$ sessions. The t1pes of information "enerated -1 these traes in Ta-$e 1 $ear$1 sho! !h1 the1 ha,e -een used for man1 1ears. There 7ust !asnBt an eas1 !a1 to "et this information from !ithin #ra$eBs interna$ ,ie!s. 8hi$e #ra$e 10" has pro,ided 5uite a fe! mehanisms to trae the session -1 5uer1in" interna$ ,ie!s4 the "eneration of trae fi$es is sti$$ around and sti$$ 5uite ,ia-$e. &n addition #ra$e 10" a$$o!s us to "enerate trae fi$es and ana$13e them !ith added funtiona$it1. This arti$e !i$$ fous in on ho! !e an "enerate trae fi$es in #ra$e 10". Table ' %aundr1 $ist of information "athered -1 train" 9:% 9tatements '2p$ain =$ans =arse4 e2eute4 and feth ounts C=F and e$apsed times =h1sia$ reads and $o"ia$ reads (um-er of ro!s proessed ;isses on the $i-rar1 ahe Fsername under !hih eah parse ourred 'ah ommit and ro$$-a0 8ait e,ent data +o! operations $o"ia$4 ph1sia$ and e$apsed times &/# t1pes (reating a Trace #$d ;ethod &t use to -e that if 1ou !anted to reate a trae fi$e 1ou had to ena-$e it at the session $e,e$ throu"h the use of the *.;)9'99&#(.9:%)T+/C' proedure or throu"h the /%T'+ 9'99&#( 9'T 9:%)T+/C' ommand. 8hi$e these aomp$ished the tas0 !e !i$$ 5ui0$1 see the1 are ,er1 $imited in sope ompared !ith the ne! method. (ot on$1 are the1 $imited in sope there usa"e is 5uite $imited. &n order to use these t!o statements 1ou need to issue them from the onneted session. That means that if 1ou !anted to "enerate a trae fi$e 1our app$iation !ou$d need to -e modified to issue these ommands. ;an1 pro"rammers "ot around this -1 readin" a ontro$ struture durin" e2eution to see if the1 shou$d turn on trae. /nd if someone !anted to trae an app$iation the1 !ou$d 7ust f$ip a f$a" in the ontro$ struture. .e$o! are t!o e2amp$es 7ust in ase 1ou !ish to tr1 these methods or ha,e a need. S)&* exec %bms_session+set_s,l_trace-tr$e./ S)&* 0&TER SESSION SET S)&_TR0(E 1 TR2E/ Ne" Met3o% Fsin" *.;9);#(&T#+ =a0a"e to "enerate trae fi$es &n =art &&& of this series !e disussed ho! to "enerate trae fi$es !ith the *.;9);#(&T#+ pa0a"e. +e,isit Ta-$e 2 and ta0e a $oo0 at the proedure a$$s re5uired to "enerate a trae fi$e. .e sure to $oo0 at the desription -o2 and e2amp$e "i,en as it si"nifies the method 1ou an trae a"ainst (-1 C%&'(T)&*'(T&F&'+4 9'+?&C')(/;'4 ;#*F%'4 /CT&#( or 9&*). &n #ra$e 10"4 !e ha,e -een "i,en the *.;9);#(&T#+ pa0a"e. This pa0a"e a$$o!s us to interat and ontro$ the train" and statistis "atherin" of sessions throu"h a =%/9:% interfae !hih & thin0 is muh easier than the o$d method of *.;9)9'99&#( and /%T'+ 9'99&#( ommands. /$so these methods in ta-$e 2 "i,e 1ou more f$e2a-i$it1 in !hat 1ou an trae a"ainst. <ou are no! a-$e to do fine "rain or "roup train" aross sessions "i,in" 1ou the *./ muh needed ontro$. /$so remem-er from =art &&& there is the audita-i$it1 of the train" throu"h the #ra$e *./)'(/.%'*)T+/C'9 ,ie! to sho! 1ou !hat train" 1ou ha,e ena-$ed. These ne! methods a$so "i,e the *./ the a-i$it1 to ena-$e trae for sessions and those app$iations do not need to issue the ommand themse$,es. Table 2 =ro"ram *esription (otes (&IENT_ID_TR0(E_EN0 B&E 'na-$e / *isa-$e Train" for / "i,en C$ient &dentifier Trae data ma1 -e !ritten to man1 trae fi$es as the trae ma1 effet mu$tip$e onneted sessions !ith the same $ient identifier. (&IENT_ID_TR0(E_DIS0 B&E 'na-$e train" for C%&'(T)&*'(T&F&'+ 7ohnn1G127.0.0.2 !ith !ait information -ut no -ind information '>'CFT' *.;9);#(&T#+.C%&'(T)&*)T+/C')'(/.%'(B7ohnn1G12 7G0.0.2B4T+F'4F/%9')K SER!_MOD_0(T_TR0(E _EN0B&E 'na-$e / *isa-$e Train" for (9er,ie (ame/-OD(LE0ACTION) om-ination. Trae data ma1 -e !ritten to man1 trae fi$es as the trae ma1 effet mu$tip$e onneted sessions. SER!_MOD_0(T_TR0(E _DIS0B&E 'na-$e train" for ser,ide)name A+ -ut on$1 for the /**';=%#<'' modu$e and in$ude !ait and -ind information. '>'CFT' *.;9);#(&T#+.9'+?);#*)/CT)T+/C')'(/.%'(BA+B 4B/**';=%#<''B4 *.;9);#(&T#+./%%)/CT&#(94T+F'4T+F'4(F%%)K SESSION_TR0(E_EN0B& E 'na-$e / *isa-$e Train" for a session identifier (9&*) 9ession must e2ist Traes on$1 a "i,en session 'na-$es / *isa-$es a trae for the instane su-mitter is onneted to. SESSION_TR0(E_EIS0B& E 'na-$e train" for session id 1L2 and in$ude !ait and -ind =ro"ram *esription (otes information E4E(2TE DBMS_MONITOR+SESSION_TR0(E_EN0B&E-'567357 TR2E7 TR2E./ 8here is m1 trae fi$e 8hen 1ou ena-$e traes #ra$e dumps this information out to a s1stem fi$e in a destination on dis0 referred to as F9'+)*F;=)*'9T. This is an atua$ parameter !ithin #ra$e and 1ou !i$$ need to 0no! !hat it is set to if 1ou e,er !ant to ,ie! the ontents of the trae fi$e 1ou 7ust "enerated. There are a oup$e !a1s 1ou an determine this parameter that & ha,e "i,en -e$o!. S)& * s3o" parameter $ser_%$mp_%est S)& * select 8al$e 9rom 8:parameter "3ere name 1 ;$ser_%$mp_%est;/ 8hen 1ou "o searhin" for 1our trae fi$e in the F9'+)*F;=)*'9T area 1ou ma1 5ui0$1 find that it is $oaded !ith other usersB trae fi$es. To ma0e matters !orse #ra$e "enerates a some!hat ripti name for 1our trae fi$e that ma0es it some!hat hard for 1ou to find them. <ou an modif1 the name of the trae fi$e -1 addin" a T+/C'F&%')&*'(T&F&'+ to it. <ou an do this -1 an /%T'+ 9'99&#( ommand suh as !hat is -e$o!. S)& * alter session set TR0(E<I&E_IDENTI<IER 1 ;somet3ing_3ere;/ 8hi$e !e an "et a $ot of rea$6time session information throu"h #ra$e interna$ ,ie!s4 the #ra$e trae sti$$ a ,a$ua-$e too$ for e2tratin" statistis for a sin"$e session or aross a "roupin" of sessions -1 the added funtiona$it1 "i,en throu"h the *.;9);#(&T#+ pa0a"e. /fter "eneratin" trae fi$es4 !e an no! use the TK=+#F or ne! #ra$e 10" trsess uti$it1 to e2trat and read the o$$eted information in a reada-$e form. .ut that is ne2t time and !i$$ !rap up this series. Oracle Session Tracing Part !I James F. Koopmann posted D/21/2007 | Comments (2) =art ?& in our series !i$$ sho! 1ou ho! to aess and "enerate reports off of the trae fi$es !e "enerated in =art ? throu"h the use of the TK=+#F and trsess uti$ities. &n the $ast part of this series !e re6,isited methods on ho! to "enerate trae fi$es. These trae fi$es "enerated !ere in a ra! format that doesnBt a$$o! for us to read them ,er1 easi$1. This arti$e !i$$ -e the $ast in this series and !i$$ sho! ho! to ta0e these "enerated trae fi$es and produe reports in a more reada-$e form. =3at %oes a trace 9ile look like &n =art &? of this series !e disussed ho! to find !here 1our trae fi$es are "enerated -ut are t1pia$$1 stored in the @#+/C%')./9'/9&*/udump diretor1 of the data-ase ser,er. %istin" 1 "i,es the top end of a trae fi$e & "enerated so that 1ou ou$d "et a f$a,or if 1ou ha,e ne,er seen a trae fi$e -efore. Throu"h out this series !e ha,e 3eroed in on settin" and monitorin" the 9'99&#()&*4 C%&'(T)&*'(T&F&'+4 9'+?&C')(/;'4 ;#*F%')(/;'4 and /CT&#()(/;' en,ironment ,aria-$es. /t the -ottom of this a--re,iated trae fi$e $istin" (%istin" 1) 1ou an see e2at$1 ho! #ra$e no! stores this in eah and e,er1 trae fi$e. (ote that 1ou an han"e these en,ironment ,aria-$es throu"hout an app$iation and these output $ines ma1 -e sattered throu"hout a trae fi$e. /$so4 & ha,e e2p$iit$1 defined eah of these $ient ,aria-$es so as to sho! them here -ut if 1ou !ere not to ha,e set them 1ou !ou$d end up !ith an empt1 strin" for those ,aria-$es. &f !e !ere to set these ,aria-$es re$i"ious$14 1ou an see ho! eas1 it is to issue a Fni2 H+'= ommand or 8indo!s F&(* ommand to "i,e 1ou a$$ the trae fi$es "enerated -1 a partiu$ar user4 !as in a partiu$ar modu$e4 or !as performin" a ertain t1pe of tas0. ListinF 1 T3; ;art 3f a trace fi.e 555 TRACE D(-P CONTIN(ED FRO- FILE 555 Du2; fi.e c,N3rac.eNad2inN.aFerNudu2;N.aFer_3ra_21==_9f:/trc Tue Jan 28 =H,"E,8! 2==8 ORACLE )1=/1/=/2/= 7 Pr3ducti3n vsnstaO= vsns>.O14 vsn@trO4 Orac.e DataDase 1=F Enter;rise Editi3n Re.ease 1=/1/=/2/= 7 Pr3ducti3n Gith the Partiti3ninF* OLAP and Data -ininF 3;ti3ns Gind3Bs 2=== )ersi3n )8/= Service Pac: " CP( , 1 7 t?;e 8E! Pr3cess Affinit?, =@======== -e23r? A0P# , PM,1H-08=H-* PG,!44-012"<-* )A,1<82-02="<- Instance na2e, .aFer Red3 thread 23unted D? this instance, 1 Orac.e ;r3cess nu2Der, 1H Gind3Bs thread id, 21==* i2aFe, ORACLE/E&E SMAD# 555 2==87=1728 =H,"E,8!/E<8 555 ACTION NA-E,ADD# 2==87=1728 =H,"E,8!/E8H 555 -OD(LE NA-E,E-P_-AINT# 2==87=1728 =H,"E,8!/E8H 555 SER)ICE NA-E,S%S6(SERS# 2==87=1728 =H,"E,8!/E8H 555 CLIENT ID, Ja2esKF/KL33;2ann,PINEMORSENFINE7ALE# 2==87=1728 =H,"E,8!/E8H 555 SESSION ID,1"E/12# 2==87=1728 =H,"E,8!/E8H =3at is t3e trcsess 2tilit# /fter 1ou ha,e determined !hih trae fi$es in$ude the partiu$ar om-inations of 9&*4 C%&'(T)&*'(T&F&'+4 9'+?&C')(/;'4 /CT&#()(/;4 or ;#*F%')(/;' ,aria-$es 1ou need to -e a-$e to pu$$ a$$ the information to"ether for ana$1sis. The trsess uti$it1 is a 7a,a app that "ets e2euted throu"h the ommand $ine of 1our #/9 and !i$$ onso$idate trae information in mu$tip$e trae fi$es for the information aross these 9&*4 C%&'(T)&*'(T&F&'+4 9'+?&C')(/;'4 /CT&#()(/;'4 and ;#*F%')(/;' ,aria-$es. (ot to !orr1 a-out in,o0in" 7a,a4 #ra$e has pro,ided a she$$ sript for 1ou partiu$ar operatin" s1stem that an -e e2euted instead. The output of the trsess uti$it1 is a sin"$e fi$e that an -e the input into the TK=+#F reportin" uti$it1. This is of "reat importane for findin" true -ott$ene0s or an app$iation that is onsumin" $ar"e amounts of resoures. &t !ou$d -e near$1 impossi-$e to ta$$1 a$$ the trae fi$es for a$$ the indi,idua$ times an app$iation or user aessed the data-ase !ithout this uti$it1. /$so it "i,es us the a-i$it1 to pi0 out of a trae fi$e4 if !e set /CT&#()(/;' and ;#*F%')(/;' proper$14 the statistis "enerated around a ertain app$iation or statement t1pes aross trae fi$es. /$so if 1ou are in a onnetion po$$in" en,ironment !here the userBs session is ne,er the same4 this uti$it1 "i,es 1ou the a-i$it1 to 3ero in and pi0 out that user easi$1 from a$$ the trae fi$es "enerated durin" the performane tunin" time s$ie 1ou are interested in and "i,in" 1ou a true $oo0 into the userBs session. %istin" 2 "i,es the s1nta2 for the ne! trsess uti$it1 and a simp$e e2amp$e. ListinF 2 S?nta@ R E@a2;.e f3r trcsess trcsess S3ut;ut O 3ut;ut_fi.e_na2eT Ssessi3n O sessi3n_IdT Sc.ientid O c.ient_IdT Sservice O service_na2eT Sacti3n O acti3n_na2eT S23du.e O 23du.e_na2eT Strace_fi.esT E@a2;.e, C3ns3.idate a.. trace fi.es f3r ever?3ne that has Deen in the E2;.3?ee -aintenance -3du.e E-P_-AINT#/ SAL I trcsess 3ut;utOe2;_2aint/trc 23du.eOE-P_-AINT 5/trc =3at (an T>PRO< Do Fp to this point !e ha,e 7ust "enerated trae fi$es and onso$idated trae fi$es -ased on a searh riteria throu"h the trsess uti$it1. /s stated -efore4 1ou an edit these trae fi$es and read them -1 hand -ut the1 do tend to -e r1pti. #ra$e has pro,ides us !ith a reportin" mehanism on these trae fi$es in the form of the TK=+#F uti$it1. This uti$it1 pro,ides for the fo$$o!in" mehanisms. %istin" C a$so "i,es the s1nta2 and e2amp$e on runnin" the TK=+#F uti$it1. Formats a$$ the r1pti information in a more reada-$e form that is understanda-$e for 1ou and me. .rea0s out eah statement e2euted durin" the trae period and present ,arious statistis that ena-$e us to determine !here -ott$ene0s $a1 and !here !e mi"ht spend our time tunin" app$iation ode. Can "enerate a 9:% sript that a$$o!s us to store the aptured statistis into a data-ase. 8i$$ determine the e2p$ain p$an for e2euted 9:% statements. =ro,ides for summar1 as !e$$ as detai$ information for o$$eted statistis ListinF 4 S?nta@ R E@a2;.e f3r TLPROF t:;r3f trace_fi.e re;3rt_fi.e SBaits O ?es+n3T Ss3rt O 3;ti3nT S;rint O nT SaFFreFate O ?es+n3T Sinsert O fi.ena2e4T Ss?s O ?es+n3T StaD.e O sche2a/taD.eT Se@;.ain O user0;assB3rdT Srec3rd O fi.ena2e"T SBidth O nT E@a2;.e, Pr3duce re;3rt f3r a.. users Bithin the E2;.3?ee -aintenance -3du.e E-P_-AINT#/ SAL I t:;r3f e2;_2aint/trc e2;_2aint/r;t Sa2;.e Out;ut, TLPROF, Re.ease 1=/1/=/2/= 7 Pr3ducti3n 3n Tue Jan 28 1=,4",2< 2==8 C3;?riFht c# 1HE2* 2=="* Orac.e/ A.. riFhts reserved/ Trace fi.e, e2;_2aint/trc S3rt 3;ti3ns, defau.t 555555555555555555555555555555555555555555555555555555555555555555555555555 c3unt O nu2Der 3f ti2es OCI ;r3cedure Bas e@ecuted c;u O c;u ti2e in sec3nds e@ecutinF e.a;sed O e.a;sed ti2e in sec3nds e@ecutinF dis: O nu2Der 3f ;h?sica. reads 3f Duffers fr32 dis: >uer? O nu2Der 3f Duffers F3tten f3r c3nsistent read current O nu2Der 3f Duffers F3tten in current 23de usua..? f3r u;date# r3Bs O nu2Der 3f r3Bs ;r3cessed D? the fetch 3r e@ecute ca.. 555555555555555555555555555555555555555555555555555555555555555555555555555 (PDATE e2; SET sa.ar? O 48==== GMERE e2;id O 1=1 ca.. c3unt c;u e.a;sed dis: >uer? current r3Bs 7777777 777777 77777777 7777777777 7777777777 7777777777 7777777777 7777777777 Parse 2 =/== =/=" = 1 = = E@ecute 2 =/== =/=1 = 1" ! 2 Fetch = =/== =/== = = = = 7777777 777777 77777777 7777777777 7777777777 7777777777 7777777777 7777777777 t3ta. " =/== =/=8 = 18 ! 2 -isses in .iDrar? cache durinF ;arse, 1 O;ti2iQer 23de, ALL_ROGS ParsinF user id, << R3Bs R3B S3urce O;erati3n 7777777 777777777777777777777777777777777777777777777777777 = (PDATE crO< ;rO= ;BO= ti2eO48= us# 1 TABLE ACCESS F(LL E-P crO< ;rO= ;BO= ti2eO1!= us# 55555555555555555555555555555555555555555555555555555555555555555555555555555 555 O)ERALL TOTALS FOR ALL NON7REC(RSI)E STATE-ENTS ca.. c3unt c;u e.a;sed dis: >uer? current r3Bs 7777777 777777 77777777 7777777777 7777777777 7777777777 7777777777 7777777777 Parse H =/=" =/=! = 2 = = E@ecute 11 =/=1 =/=" = 21 E 4 Fetch = =/== =/== = = = = 7777777 777777 77777777 7777777777 7777777777 7777777777 7777777777 7777777777 t3ta. 2= =/=! =/11 = 24 E 4 -isses in .iDrar? cache durinF ;arse, ! -isses in .iDrar? cache durinF e@ecute, 2 O)ERALL TOTALS FOR ALL REC(RSI)E STATE-ENTS ca.. c3unt c;u e.a;sed dis: >uer? current r3Bs 7777777 777777 77777777 7777777777 7777777777 7777777777 7777777777 7777777777 Parse 2 =/=1 =/== = = = = E@ecute 2 =/== =/== = = = = Fetch 2 =/== =/== = 1" = 2 7777777 777777 77777777 7777777777 7777777777 7777777777 7777777777 7777777777 t3ta. ! =/=1 =/=1 = 1" = 2 -isses in .iDrar? cache durinF ;arse, 2 14 user SAL state2ents in sessi3n/ = interna. SAL state2ents in sessi3n/ 14 SAL state2ents in sessi3n/ 55555555555555555555555555555555555555555555555555555555555555555555555555555 555 Trace fi.e, e2;_2aint/trc Trace fi.e c32;atiDi.it?, 1=/=1/== S3rt 3;ti3ns, defau.t = sessi3n in tracefi.e/ 14 user SAL state2ents in trace fi.e/ = interna. SAL state2ents in trace fi.e/ 14 SAL state2ents in trace fi.e/ 1= uni>ue SAL state2ents in trace fi.e/ 1=2 .ines in trace fi.e/ E1! e.a;sed sec3nds in trace fi.e/ Tracing En3ancements The !or$d of train" #ra$e sessions has han"ed drastia$$1 !ith #ra$e 10". (ot so muh as the mehanisms -ut in the !a1 !e an initiate a trae for one session or a "roup of sessions. 8e are no! a-$e to Mta"M sessions as the1 are onneted to #ra$e and mo,e throu"h app$iations. 8e an no! aurate$1 pinpoint !here in the app$iation a session is4 the amount of resoures -ein" onsumed4 and more important$1 if the session is ha,in" diffiu$t1 and is in need of tunin". This is e2treme$1 important in a mu$ti6tier en,ironment !here onnetion po$$in" ta0es p$ae and !e !ou$d -e $ost if it !here not for these ne! train" features.