Automatic PGA Management

9
Activating, Monitoring, and Tuning Automatic PGA Memory Management via PGA_AGGREGATE_TARGET Under Oracle 9i By Jim Czuprynski Synopsis. Sizing the Program Global Area (PGA) is now one of many tasks made simpler under Oracle 9i. This article discusses how a database server utilizes the PGA, how the PGA can be automatically sized using PGA_AGGREGATE_TARGET initialization parameter, and how the PGA's size can be monitored and tuned using some new dynamic database views now part of 9i. As Oracle DBAs, we typically spend considerable time planning, sizing, and monitoring the System Global Area (SGA) because of its importance to our databases' performance. However, the Program Global Area (PGA) can be equally important to throughput and performance because it's where database applications do much of their work. Recently I had the chance to delve into the PGA's inner workings during a conversion of several Oracle 8i databases to the Oracle 9iR2 environment. I found that under 9i, it is even easier to monitor what is going on inside the PGA, and with the new Automatic PGA Memory Management features of 9i, Oracle now manages sizing for dedicated sessions. (We'll talk about how the PGA is managed for shared sessions a bit later.) First, some details. Our current production database uses Oracle 9iR2 in a Windows 2000 Advanced Server environment. The database server needs to support a minimum of 200 dedicated connections for our primary Powerbuilder client- server applications. The database also supports a few dozen shared connections for some web and reporting applications, but the majority of the production server is dedicated for online transaction processing (OLTP). Since the database has to manage a considerable number of dedicated connections for OLTP processing, the PGA needed to be configured for maximum efficiency. PGA Architecture: Work Areas Oracle defines the PGA as a private memory region containing data and control information for a server process. Essentially, it is where the run time version of the code that

description

,,,,

Transcript of Automatic PGA Management

Activating, Monitoring, and TuningAutomatic PGA Memory Management via PGA_AGGREGATE_TARGET Under Oracle 9iBy Jim Cu!ryn"#iSynopsis. Sizing the Program Global Area (PGA) is now one of many tasks made simpler under Oracle 9i !his article discusses how a database ser"er utilizes the PGA# how the PGA can be automatically sized using PGA$AGG%&GA!&$!A%G&! initialization parameter# and how the PGA's size can be monitored and tuned using some new dynamic database "iews now part of 9i As Oracle DBAs, we typically spend considerable time planning, sizing, and monitoring the System Global Area (SGA) because of its importance to our databases performance! "owe#er, the $rogram Global Area ($GA) can be e%ually important to throughput and performance because its where database applications do much of their wor&! 'ecently ( had the chance to del#e into the $GAs inner wor&ings during a con#ersion of se#eral Oracle )i databases to the Oracle *i'+ en#ironment! ( found that under *i, it is e#eneasier to monitor what is going on inside the $GA, and with the new Automatic $GA ,emory,anagement features of *i, Oracle now manages sizing for dedicated sessions! (-ell tal& about how the $GA is managed for shared sessions a bit later!).irst, some details! Our current production database uses Oracle *i'+ in a -indows +/// Ad#anced Ser#er en#ironment! 0he database ser#er needs to support a minimum of +// dedicated connections for our primary $owerbuilder client1ser#er applications! 0he database also supports a few dozen shared connections for some web and reporting applications, but the ma2ority of the production ser#er is dedicated for online transaction processing (O30$)! Since the database has to manage a considerable number of dedicated connections for O30$processing, the $GA needed to be configured for ma4imum efficiency!PGA Architecture: Work AreasOracle defines the $GA as a pri"ate memory region containing data and control information for a ser"er process 5ssentially, it is where the run time #ersion of the code that is being e4ecuted is stored temporarily11for e4ample, the runtime area of a cursor!6omple4 %ueries11for e4ample, ones that use a lot of sorting (G'O7$ B8, O'D5' B8, 'O337$), or whose %uery access plans utilize hash 2oins, bitmap merges, and bitmap creates11tend to allocate a large portion of this runtime area for wor& areas for these memory1intensi#e operations! (n addition, bul&1loading operations that re%uire large write buffers need large wor& areas! 5ssentially, how a wor& area is sized determines the efficiency and speed of the %uery! .or the best results the wor& area for, say, a large %uery with a lot of sorting should be large enough that all its input data and au4iliary memory structures created by its S93 operators will fit inside that wor& area! Oracle terms this the optimal size of a wor& area!So, what happens when the wor& areas size is e4ceeded: 'esponse time increases because the ser#er process has to ma&e an e4tra pass o#er the input data (termed the one(pass sizeof the wor& area)! ,oreo#er, if the wor& area is e4ceedingly small, the ser#er process has toma&e multiple passes o#er the wor& area (termed the multi(pass size of the wor& area)! 0uning the wor& areas in the $GA so that the %uery runs within the optimal size of the wor& area eliminates these additional passes o#er the input data, insuring the %uery runs faster and uses $GA resources more efficiently!Automatic PGA Memory ManagementBefore Oracle *i, the ma4imum size of wor& areas was based on #alues set for the SO'0;A'5A;S( of the total memory a#ailable for the database instance to allow enough memory for other non1Oracle applications running on the ser#er!(n my case, my ser#er had )GB a#ailable memory for the instance! .or an O30$1based ser#er, Oracle recommends allocating +/> to the $GA, so $GA;AGG'5GA05;0A'G50 would be set to appro4imately ?@?/,B (()?*+ ,B 4 )/>) 4 +/>)! .or a DSS1based ser#er, Oraclerecommends a factor of at least A/>, or appro4imately @+BC,B ()?*+,B 4 )/>) 4 A/>)! During my testing, ( hedged my bet by %uite a bit, &nowing that my database ser#er is almost totally dedicated to O30$, and initially allocated D//,B for $GA;AGG'5GA05;0A'G50!After applying the change to my databases (E(0!O'A file and restarting the database, ( confirmed the results by %uerying $%PGA&TAT' 0his is a new dynamic #iew a#ailable with Oracle *i and is useful for obtaining instance1le#el statistics about $GA memory usage and how well automatic memory management is wor&ingFS93G S53560 EA,5, HA375 .'O, #Ipgastat=EA,5 HA37511111111111111111111111111111111111111111111111aggregate $GA target parameter D?*D@/D//aggregate $GA auto target @C?D@@/))global memory bound +/*B?A+/total $GA inuse ?B)@@*)Dtotal $GA allocated @D)?/))/ma4imum $GA allocated ?+D@?)B+/total freeable $GA memory /$GA memory freed bac& to OS /total $GA used for auto wor&areas /ma4imum $GA used for auto wor&areas C/+/D/@+total $GA used for manual wor&areas /ma4imum $GA used for manual wor&areas +DCB)Do#er allocation count /total bytes processed A)CC+*@+D)e4tra bytes readJwritten B+//*A+@+cache hit percentage )*!/C0he statistics returned e4plain whats going on inside the $GA! "ere is a brea&out of the more important ones, according to OracleF aggregate PGA target parameter shows the actual #alue set for $GA;AGG'5GA05;0A'G50 (in this case, D//,B)! 0his parameter confirms if automatic $GA memory management has been acti#ated11if it hasnt been, then this #alue will be zero! 0he Oracle DB,S dynamically deri#es the #alue for aggregate PGA auto target from the #alue set for $GA;AGG'5GA05;0A'G50 and is continuously ad2usted by Oracle! (t is the amount of memory that can be used for wor& areas running in automatic mode! (f this #alue is small, it generally indicates that other components of the system11for e4ample, $3JS93 or Ka#a memory11are using a lot of $GA, lea#ing little behind for wor& areas to be managed in automatic mode! global memory bound shows the ma4imum size of a wor& area e4ecuted in automaticmode! 0he #alue is constantly ad2usted by Oracle based on the current state of the wor& area wor&load and generally decreases when the number of acti#e wor& areas increase! Oracle recommends that this #alue should ne#er reach ?,B= if it does, its probably an indicator that $GA;AGG'5GA05;0A'G50 should be increased! total PGA allocated yields the total amount of $GA memory that Oracle has allocated for the instance, while total PGA used for auto workareas tells how much memory is in use by other processes li&e $3JS93 or Ka#a! Subtracting the second number from the first yields the total $GA memory used by these other processes! o"er allocation count tells how much $GA memory has been o#er1allocated cumulati#ely since the instance was started! (f the #alue returned is anything o#er zero, it is an indication that the size of $GA;AGG'5GA05;0A'G50 should be increased because it means that Oracle could not honor at least one re%uest for additional $GA wor& areas! total bytes processed represents how many bytes were processed since instance startup, while e)tra bytes read*written represents how many bytes were processed #ia one1pass or multi1pass processing! 0hese two #alues are used to calculate the cache hit percentage based on the following formulaF (?// L total bytes processed) J(total bytes processed M e4tra bytes readJwritten)! Monitoring PGA Memory U"ageOnce enough processing cycles ha#e elapsed for the database, it is time to determine if the initial $GA size was underestimated (or perhaps e#en o#erestimated)! Oracle *i pro#ides se#eral dynamic #iews for monitoring how well the database is managing $GA memory allocations!9uerying $%PROCE&& lets us see how Oracle processes are utilizing $GA memory, especially what $GA memory is in use, how much has been allocated, and whats the high1water mar& for $GA memory for the processFSELECT program, pga_used_mem "PGA Used", pga_alloc_mem "PGA Alloc", pga_max_mem "PGA Max"FROM vprocess!PROGRAM PGA Used PGA Alloc PGA Max"""""""""""""""" """"""""""" """"""""""" """"""""""ORACLE#E$E %&'()* %+*+'( %+*+'(###$%&()_*OR+AREA_,-&TOGRAM contains information about how many wor& areas ha#ebeen e4ecuted with optimal, one1pass, and multi1pass memory size since the instance was started within a range of wor& area sizes, defined by 3O-;O$0(,A3;S(