Oracle memory structure (part 3)
[In-depth analysis-eygle] Study Notes
1.2.3 PGA management:
sys@felix SQL>show parameter area_size NAME TYPE VALUE------------------------------------ ----------------------------------------------------bitmap_merge_area_size integer 1048576create_bitmap_area_size integer 8388608hash_area_size integer 131072sort_area_size integer 65536workarea_size_policy string AUTO
Automatic SQL Execution Memory Management, also known as automatic PGA Management, uses this new feature, oracle can automatically manage and adjust the SQL Memory zone under the overall PGA usage limit, which greatly simplifies DBA's work? High database performance.
To achieve automatic PGA management, Oracle introduces several new initialization parameters:
(1) PGA_AGGREGATE_TARGET this parameter is used to specify the maximum PGA memory available for all sessions. This parameter can be dynamically changed. The value range is from 10 MB ~ (4096G-1) bytes.
(2) WORKAREA_SIZE_POLICY this parameter is used to switch the automatic PGA memory management function. This parameter has two options: AUTO and MANUAL. When set to AUTO, the database uses the automatic PGA management function, when it is set to MANUAL, the previous MANUAL management method is still used.
By default, the parameter WORKAREA_SIZE_POLICY is set to AUTO.
sys@felix SQL>show parameterWORKAREA_SIZE_POLIC NAME TYPE VALUE---------------------------------------------------------- --------workarea_size_policy string AUTO
In addition, in different versions, automatic PGA management has different categories:
(1) In Oracle9i,The PGA_AGGREGATE_TARGET parameter is valid only for dedicated connections of the DedicatedServer in dedicated Server mode, but not for Shared Server connections.
(2)PGA_AGGREGATE_TARGET takes effect for both dedicated server connections and shared server connections starting from Oracle10g.
1.2.4 parameter settings and Memory Allocation
The workspace performance is expected to achieve the following goals:
Workarea execution-optimal> = 90%
Workarea execution-multipass = 0%
PGA performance indicator script of the production system:
SELECT NAME, VALUE, 100 * (VALUE / DECODE((SELECT SUM(VALUE) FROM v$sysstat WHERE NAME LIKE'workarea executions%'), 0, NULL, (SELECT SUM(VALUE) FROM v$sysstat WHERE NAME LIKE'workarea executions%'))) pct FROMv$sysstat WHERE NAMELIKE 'workarea executions%';
<strong>sys@felix SQL>select description,dest fromx$messages where description like 'SQL Memory%'; DESCRIPTION DEST-------------------------------------------------- ----------SQL Memory Management Calculation CKPT 15:26:04 sys@felix SQL></strong>
sys@felix SQL>select * from v$pgastat;NAME VALUE UNIT---------------------------------------- ---------- ------------------------aggregate PGA target parameter 146800640 bytesaggregate PGA auto target 22099968 bytesglobal memory bound 29360128 bytestotal PGA inuse 122360832 bytestotal PGA allocated 144107520 bytesmaximum PGA allocated 163160064 bytestotal freeable PGA memory 11141120 bytesprocess count 32max processes count 36PGA memory freed back to OS 374669312 bytestotal PGA used for auto workareas 0 bytesmaximum PGA used for auto workareas 6313984 bytestotal PGA used for manual workareas 0 bytesmaximum PGA used for manual workareas 0 bytesover allocation count 0bytes processed 232915968 bytesextra bytes read/written 0 bytescache hit percentage 100 percentrecompute count (total) 600419 rows selected.
1.2.6 PGA adjustment suggestions
With the introduction of the automatic PGA adjustment function, Oracle also introduces the corresponding dynamic performance view for optimization recommendations. The PGA optimization recommendations are provided through v $ pga_target_advice and v $ pga_target_advice_histogra. The v $ pga_target_advice view evaluates different PGA settings and provides information such as the PGA hit rate and OverAlloc under different settings.
15:32:23 sys@felix SQL>select PGA_TARGET_FOR_ESTIMATE/1024/1024 PGAMB, PGA_TARGET_FACTOR, 15:37:08 2 ESTD_PGA_CACHE_HIT_PERCENTAGE, ESTD_OVERALLOC_COUNT15:37:08 3 from v$pga_target_advice; PGAMB PGA_TARGET_FACTOR ESTD_PGA_CACHE_HIT_PERCENTAGE ESTD_OVERALLOC_COUNT---------- ----------------- ----------------------------- -------------------- 17.5 .125 85 4 35 .25 85 4 70 .5 85 4 105 .75 85 4 140 1 100 0 168 1.2 100 0 196 1.4 100 0 224 1.6 100 0 252 1.8 100 0 280 2 100 0 420 3 100 0 560 4 100 0 840 6 100 0 1120 8 100 0
V $ pga_target_advice_histogram view can be evaluated by sampling different workspace sizes? For Statistics
For analysis. Several important fields are:
(1) minimum Optimal limit (bytes) within the LOW_OPTIMAL_SIZE-Histogram evaluation range)
(2) HIGH_OPTIMAL_SIZE-Histogram assessment range within the Optimal upper limit (bytes)
(3) Estimated number of optimal executions within the ESTD_OPTIMAL_EXECUTIONS-Histogram evaluation Interval
(4) Estimation of onepass executions within the ESTD_ONEPASS_EXECUTIONS-Histogram evaluation Interval
(5) Estimated number of multipass executions in the ESTD_MULTIPASSES_EXECUTIONS-Histogram evaluation Interval
(6) estimated total number of executions within the ESTD_TOTAL_EXECUTIONS-Histogram evaluation Interval
SELECT pga_target_factor factor, low_optimal_size / 1024 low, ROUND(high_optimal_size / 1024) high, estd_optimal_executions estd_opt, estd_onepass_executions estd_op, estd_multipasses_executions estd_mp, estd_total_executions estd_exec FROM v$pga_target_advice_histogram WHERE pga_target_factor = 0.25 AND estd_total_executions > 0;
</pre><pre name="code" class="html">
<span style="font-family: Arial, Helvetica, sans-serif;"></span>
<Span style = "font-family: Arial, Helvetica, sans-serif; "> heap name =" pga heap "desc = 0xbaf3ca0 -- note here </span> </strong> </span>
extentsz=0x20c0 alt=216 het=32767 rec=0 flg=3 opc=2 parent=(nil)owner=(nil) nex=(nil) xsz=0xfff0 heap=(nil) fl2=0x60,nex=(nil), dsxvers=1, dsxflg=0x0 dsx firstext=0xf7fa7720EXTENT 0 addr=0x7fadf7c72010 Chunk 7fadf7c72020 sz= 65504 free " "EXTENT 1 addr=0x7fadf7d00010 Chunk 7fadf7d00020 sz= 28920 perm "perm " alo=9384 Chunk 7fadf7d07118 sz= 7656 free " " Chunk 7fadf7d08f00 sz= 4224 freeable "diag pga " ds=0x7fadf82157e0 Chunk 7fadf7d09f80 sz= 4224 freeable "diag pga " ds=0x7fadf82157e0/heap Chunk 7fadf7fd28d0 sz= 7608 perm "perm " alo=7608 Chunk 7fadf7fd4688 sz= 40 free " " Chunk 7fadf7fd46b0 sz= 80 freeable "dbgdInitEventGr" Chunk 7fadf7fd4700 sz= 184 freeable "sdbgrf: iosb " Chunk 7fadf7fd47b8 sz= 80 freeable "skgfzctx " Chunk 7fadf7fd4808 sz= 376 freeable "PLS cca hpdesc"EXTENT 18 addr=0x7fadf7fcd860 Chunk 7fadf7fcd870 sz= 20512 perm "perm " alo=20512EXTENT 19 addr=0x7fadf7fc9958 Chunk 7fadf7fc9968 sz= 16072 perm "perm " alo=16072EXTENT 20 addr=0x7fadf7fc7868 Chunk 7fadf7fc7878 sz= 3240 perm "perm " alo=3240 Chunk 7fadf7fc8520 sz= 3184 perm "perm " alo=3184 Chunk 7fadf7fc9190 sz= 1088 perm "perm " alo=1088 Chunk 7fadf7fc95d0 sz= 168 perm "perm " alo=168 Chunk 7fadf7fc9678 sz= 48 free " " Chunk 7fadf7fc96a8 sz= 72 freeable "koh-kghu callh" Chunk 7fadf7fc96f0 sz= 568 freeable "joxp heap "EXTENT 21 addr=0x7fadf7fc5778 Chunk 7fadf7fc5788 sz= 4848 perm "perm " alo=4848 Chunk 7fadf7fc6a78 sz= 440 freeable "krbabrPgaRespMs" Chunk 7fadf7fc6c30 sz= 56 freeable "krbabrPgaReqCtx" Chunk 7fadf7fc6c68 sz= 424 freeable "krbabrPgaReqMsg" Chunk 7fadf7fc6e10 sz= 2600 freeable "kjztprq struct"EXTENT 22 addr=0x7fadf7fc3688 Chunk 7fadf7fc3698 sz= 7720 perm "perm " alo=7720 Chunk 7fadf7fc54c0 sz= 160 freeable "regheapd_kdlwpg" Chunk 7fadf7fc5560 sz= 88 freeable "KCFIS GCTX " Chunk 7fadf7fc55b8 sz= 400 freeable "krbabrPgaStbyRe"EXTENT 23 addr=0x7fadf7fb5e28 Chunk 7fadf7fb5e38 sz= 55328 perm "perm " alo=55328EXTENT 24 addr=0x7fadf7fb3d38 Chunk 7fadf7fb3d48 sz= 4888 perm "perm " alo=4888 Chunk 7fadf7fb5060 sz= 2992 recreate "KSFQ heap " latch=(nil)
Further, a specific data storage structure can be dumped out (DS). For example, the size of the space used by ds dcd00c0 is sz = 14036, first, convert the space address:
select to_number('baf3ca0','xxxxxxxxxx') from dual15:50:33 sys@felix SQL>/TO_NUMBER('BAF3CA0','XXXXXXXXXX')--------------------------------- 19603369615:50:33 sys@felix SQL>
Run the following command to dump the content of a fixed address space:
Alter session set events 'immediate trace name heapdump_addr level 1, addr n ';
You can run the following command to dump the calculated address space:
SQL> ALTER SESSIONSET EVENTS 'immediate trace name heapdump_addr level 1, addr 100 ';
Session altered.
Script for getting the dump file:
SELECT a.VALUE || b.symbol || c.instance_name || '_ora_' || d.spid || '.trc' trace_file FROM (SELECT VALUE FROM v$parameter WHERE NAME = 'user_dump_dest') a, (SELECT SUBSTR(VALUE, -6, 1) symbol FROM v$parameter WHERE NAME = 'user_dump_dest') b, (SELECT instance_name FROM v$instance) c, (SELECT spid FROM v$session s, v$process p, v$mystat m WHERE s.paddr = p.addr AND s.SID = m.SID AND m.statistic# = 0) d;
Check the process dump file to find the following Heap address information and space allocation:
[oracle@felix ~]$grep heap /u01/app/oracle/diag/rdbms/felix/felix/trace/felix_ora_6443.trc<strong><span style="color:#ff0000;">HEAP DUMP heap name="pga heap" desc=0xbaf3ca0</span></strong> parent=(nil) owner=(nil) nex=(nil) xsz=0xfff0 heap=(nil) Chunk 7fadf7fc96f0 sz= 568 freeable "joxp heap " Chunk 7fadf7fc54c0 sz= 160 freeable "regheapd_kdlwpg" Chunk 7fadf7fb5060 sz= 2992 recreate "KSFQ heap " latch=(nil) Chunk 7fadf7fb5c10 sz= 160 freeable "KSFQ heap descr" Chunk 7fadf7fb0790 sz= 232 freeable "iovecheapd_kdlw" Chunk 7fadf7fb0878 sz= 304 freeable "bcheapd_kdlwpga" Chunk 7fadf7fb09a8 sz= 208 freeable "sioheapd_kdlwpg" Chunk 7fadf7fb0ad8 sz= 160 freeable "KSZ pga subheap"Total heap size = 499952<strong><span style="color:#ff0000;">HEAP DUMP heap name="top call heap" desc=0xbaf94e0</span></strong> parent=(nil) owner=(nil) nex=(nil) xsz=0xfff8 heap=(nil) Chunk 7fadf7ccb7d8 sz= 1032 recreate "callheap " latch=(nil) Chunk 7fadf7cceb78 sz= 4224 freeable "callheap " ds=0xbaf85c0 Chunk 7fadf7ccfbf8 sz= 1032 recreate "callheap " latch=(nil)Total heap size = 524096
<strong><span style="color:#ff0000;">HEAP DUMP heap name="top uga heap" desc=0xbaf9700</span></strong> parent=(nil) owner=(nil) nex=(nil) xsz=0xfff8 heap=(nil) Chunk 7fadf7c62018 sz= 65512 freeable "session heap " ds=0x7fadf7cd5be0 Chunk 7fadf7d10018 sz= 65512 freeable "session heap " ds=0x7fadf7cd5be0 Chunk 7fadf7cf0018 sz= 65512 freeable "session heap " ds=0x7fadf7cd5be0 Chunk 7fadf7ce0068 sz= 65432 recreate "session heap " latch=(nil)Total heap size = 262048<strong><span style="color:#ff0000;">HEAP DUMP heap name="pga heap" desc=0xbaf3ca0</span></strong> parent=(nil) owner=(nil) nex=(nil) xsz=0x1fff0 heap=(nil) Chunk 7fadf7fc96f0 sz= 568 freeable "joxp heap " Chunk 7fadf7fc54c0 sz= 160 freeable "regheapd_kdlwpg" Chunk 7fadf7fb5060 sz= 2992 recreate "KSFQ heap " latch=(nil) Chunk 7fadf7fb5c10 sz= 160 freeable "KSFQ heap descr" Chunk 7fadf7fb0790 sz= 232 freeable "iovecheapd_kdlw" Chunk 7fadf7fb0878 sz= 304 freeable "bcheapd_kdlwpga" Chunk 7fadf7fb09a8 sz= 208 freeable "sioheapd_kdlwpg" Chunk 7fadf7fb0ad8 sz= 160 freeable "KSZ pga subheap"Total heap size = 827504
It can be seen from the red font above. In the automatic management mode, PGA, CGA, and UGA are allocated independently.