{"id":5266,"date":"2026-01-21T12:36:46","date_gmt":"2026-01-21T07:06:46","guid":{"rendered":"https:\/\/w3buddy.com\/?post_type=cposts&#038;p=5266"},"modified":"2026-01-21T12:36:47","modified_gmt":"2026-01-21T07:06:47","slug":"memory-architecture","status":"publish","type":"cposts","link":"https:\/\/w3buddy.com\/blog\/notes\/oracle-database-architecture\/memory-architecture\/","title":{"rendered":"MEMORY ARCHITECTURE"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\"><strong>A. SGA (System Global Area) &#8211; Shared Memory<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Purpose:<\/strong> Shared by all users and processes. Allocated at instance startup.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Main Components:<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>1. Database Buffer Cache<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Stores copies of data blocks read from datafiles<\/li>\n\n\n\n<li>When you query data, Oracle first checks here (not disk)<\/li>\n\n\n\n<li><strong>Size parameter:<\/strong> <code>DB_CACHE_SIZE<\/code> or auto-managed by <code>SGA_TARGET<\/code><\/li>\n\n\n\n<li>Uses LRU algorithm (Least Recently Used for eviction)<\/li>\n\n\n\n<li><strong>Types of buffers:<\/strong>\n<ul class=\"wp-block-list\">\n<li><strong>Dirty buffers:<\/strong> Modified but not yet written to disk<\/li>\n\n\n\n<li><strong>Clean buffers:<\/strong> Not modified or already written to disk<\/li>\n\n\n\n<li><strong>Pinned buffers:<\/strong> Currently being accessed<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>DBA concern:<\/strong> Too small = physical reads increase = slow queries<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>2. Shared Pool<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>a) Library Cache:<\/strong> Stores parsed SQL, PL\/SQL code (execution plans)<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Prevents re-parsing same queries (soft parse vs hard parse)<\/li>\n\n\n\n<li><strong>Hard parse = expensive<\/strong> (CPU intensive, takes locks)<\/li>\n\n\n\n<li><strong>Soft parse = reuses existing plan<\/strong> (fast)<\/li>\n\n\n\n<li><strong>Components:<\/strong> SQL area, PL\/SQL area, Java pool cache<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>b) Data Dictionary Cache (Row Cache):<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Metadata about tables, users, privileges, tablespaces<\/li>\n\n\n\n<li>Cached from <code>SYS<\/code> schema objects<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>c) Result Cache (19c):<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Stores query results for reuse<\/li>\n\n\n\n<li>Can dramatically improve performance for repetitive queries<\/li>\n\n\n\n<li><strong>Size parameter:<\/strong> <code>SHARED_POOL_SIZE<\/code><\/li>\n\n\n\n<li><strong>DBA concern:<\/strong> Insufficient size = hard parses spike = CPU saturation<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>3. Redo Log Buffer<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Small circular buffer for redo entries (change vectors)<\/li>\n\n\n\n<li>LGWR writes it to redo log files<\/li>\n\n\n\n<li><strong>Size parameter:<\/strong> <code>LOG_BUFFER<\/code> (typically 10-16 MB is enough)<\/li>\n\n\n\n<li>Rarely needs tuning in modern systems<\/li>\n\n\n\n<li><strong>DBA concern:<\/strong> If too small, LGWR can&#8217;t keep up = &#8220;log file sync&#8221; waits<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>4. Large Pool<\/strong> (Optional but recommended)<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Used for RMAN backup\/restore operations<\/li>\n\n\n\n<li>Parallel execution message buffers<\/li>\n\n\n\n<li>Shared server (MTS) session memory<\/li>\n\n\n\n<li><strong>Size parameter:<\/strong> <code>LARGE_POOL_SIZE<\/code><\/li>\n\n\n\n<li><strong>Best practice:<\/strong> Set to at least 128MB if using RMAN<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>5. Java Pool<\/strong> (If using Java in DB)<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>For Java stored procedures, SQLJ<\/li>\n\n\n\n<li><strong>Size parameter:<\/strong> <code>JAVA_POOL_SIZE<\/code><\/li>\n\n\n\n<li>Not needed if you don&#8217;t use Java in database<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>6. Streams Pool<\/strong> (For replication\/streams)<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Used by Oracle Streams, GoldenGate<\/li>\n\n\n\n<li><strong>Size parameter:<\/strong> <code>STREAMS_POOL_SIZE<\/code><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>7. Fixed SGA<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Internal housekeeping structures<\/li>\n\n\n\n<li>Contains general information about instance state<\/li>\n\n\n\n<li><strong>You cannot control this size<\/strong><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>INTERVIEW QUESTIONS:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q1: What is SGA and its main components?<\/strong><br><strong>A:<\/strong> SGA is System Global Area\u2014shared memory allocated at instance startup. Main components: Database Buffer Cache (data blocks), Shared Pool (parsed SQL, data dictionary), Redo Log Buffer (change vectors), and optional pools like Large Pool (RMAN) and Java Pool.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q2: What&#8217;s the difference between hard parse and soft parse?<\/strong><br><strong>A:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Hard parse:<\/strong> SQL is new, Oracle parses it, creates execution plan, stores in library cache. CPU intensive.<\/li>\n\n\n\n<li><strong>Soft parse:<\/strong> SQL already in library cache, Oracle reuses existing plan. Very fast.<\/li>\n\n\n\n<li>Use bind variables to avoid hard parses.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q3: How to reduce hard parses?<\/strong><br><strong>A:<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Use bind variables instead of literals<\/li>\n\n\n\n<li>Increase <code>SHARED_POOL_SIZE<\/code><\/li>\n\n\n\n<li>Set <code>CURSOR_SHARING=FORCE<\/code> (last resort, has side effects)<\/li>\n\n\n\n<li>Check <code>V$SQL<\/code> for similar queries with different literals<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q4: What is stored in Database Buffer Cache?<\/strong><br><strong>A:<\/strong> Copies of data blocks read from datafiles. Includes table data, index data. Uses LRU algorithm. When data is modified, blocks become &#8220;dirty&#8221; until DBWn writes them to disk.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q5: What happens when buffer cache is full?<\/strong><br><strong>A:<\/strong> Oracle uses LRU algorithm to evict least recently used clean buffers. If no clean buffers available, DBWn is signaled to write dirty buffers to disk, causing &#8220;free buffer waits&#8221; (performance issue).<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>B. PGA (Program Global Area) &#8211; Private Memory<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Purpose:<\/strong> Private memory for each server process. NOT shared.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>What&#8217;s stored in PGA:<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Session memory:<\/strong> Session variables, logon information, session cursor state<\/li>\n\n\n\n<li><strong>Private SQL area:<\/strong> Bind information, runtime memory structures<\/li>\n\n\n\n<li><strong>Sort area:<\/strong> For ORDER BY, GROUP BY, DISTINCT operations<\/li>\n\n\n\n<li><strong>Hash area:<\/strong> For hash joins<\/li>\n\n\n\n<li><strong>Bitmap merge area:<\/strong> For bitmap index operations<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Size parameters:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>PGA_AGGREGATE_TARGET<\/code> = Total PGA for all sessions (Oracle auto-manages individual allocations)<\/li>\n\n\n\n<li><code>PGA_AGGREGATE_LIMIT<\/code> = Hard limit (19c feature to prevent runaway processes from consuming all memory)<\/li>\n\n\n\n<li><code>WORKAREA_SIZE_POLICY=AUTO<\/code> (default, recommended)<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>How Oracle allocates PGA:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Oracle estimates memory needed for each operation<\/li>\n\n\n\n<li>Distributes available PGA among active operations<\/li>\n\n\n\n<li>If insufficient PGA, operations spill to TEMP tablespace (slower)<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>DBA concern:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Too small = sorts\/joins spill to TEMP tablespace (disk-based, very slow)<\/li>\n\n\n\n<li>Monitor: <code>V$PGASTAT<\/code>, <code>V$PROCESS<\/code>, <code>V$SQL_WORKAREA<\/code><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>INTERVIEW QUESTIONS:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q1: What&#8217;s the difference between SGA and PGA?<\/strong><br><strong>A:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>SGA:<\/strong> Shared memory, allocated at instance startup, used by all processes. Contains buffer cache, shared pool.<\/li>\n\n\n\n<li><strong>PGA:<\/strong> Private memory, allocated per server process, not shared. Contains sort areas, session variables, private SQL areas.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q2: What happens if PGA is insufficient?<\/strong><br><strong>A:<\/strong> Sort and hash operations spill to TEMP tablespace (disk). This causes performance degradation. You&#8217;ll see &#8220;direct path read temp&#8221; and &#8220;direct path write temp&#8221; wait events.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q3: How to identify if PGA is undersized?<\/strong><br><strong>A:<\/strong> Check:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT name, value FROM V$PGASTAT \nWHERE name IN ('over allocation count', 'global memory bound');<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If &#8220;over allocation count&#8221; &gt; 0, increase PGA. Also check <code>V$SQL_WORKAREA_ACTIVE<\/code> for operations using disk.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q4: What is PGA_AGGREGATE_LIMIT (19c)?<\/strong><br><strong>A:<\/strong> Hard limit on total PGA usage. If exceeded, Oracle terminates sessions consuming most PGA to protect instance. Prevents runaway queries from crashing the database. Default is 2x <code>PGA_AGGREGATE_TARGET<\/code> or 3GB (whichever is higher).<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>C. Automatic Memory Management (AMM vs ASMM)<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Oracle 19c offers three memory management modes:<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>1. Automatic Shared Memory Management (ASMM) &#8211; RECOMMENDED<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>SGA_TARGET = 10G          <em>-- Oracle auto-tunes components within this<\/em>\nSGA_MAX_SIZE = 12G        <em>-- Maximum SGA can grow to (requires restart to increase)<\/em>\nPGA_AGGREGATE_TARGET = 3G <em>-- Oracle manages PGA automatically<\/em><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>How it works:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You set total SGA size<\/li>\n\n\n\n<li>Oracle automatically resizes buffer cache, shared pool, large pool, java pool<\/li>\n\n\n\n<li>You can still set minimums: <code>DB_CACHE_SIZE<\/code>, <code>SHARED_POOL_SIZE<\/code> (Oracle won&#8217;t go below these)<\/li>\n\n\n\n<li><strong>Downtime needed:<\/strong> Only to increase <code>SGA_MAX_SIZE<\/code><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Best for:<\/strong> Most production systems, especially large databases<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>2. Automatic Memory Management (AMM)<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>MEMORY_TARGET = 13G       <em>-- Total memory (SGA+PGA combined)<\/em>\nMEMORY_MAX_TARGET = 16G   <em>-- Maximum total memory<\/em><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>How it works:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Oracle manages BOTH SGA and PGA automatically<\/li>\n\n\n\n<li>Can transfer memory between SGA and PGA as needed<\/li>\n\n\n\n<li>More flexible but has overhead<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Limitations:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Not supported on Linux with huge pages enabled<\/li>\n\n\n\n<li>Performance overhead on very large systems (>40GB SGA)<\/li>\n\n\n\n<li><strong>Downtime needed:<\/strong> Only to increase <code>MEMORY_MAX_TARGET<\/code><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Best for:<\/strong> Smaller databases (&lt;20GB SGA), test\/dev environments<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>3. Manual Memory Management<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>SGA_TARGET = 0                    <em>-- Disables ASMM<\/em>\nDB_CACHE_SIZE = 6G\nSHARED_POOL_SIZE = 2G\nLARGE_POOL_SIZE = 256M\nLOG_BUFFER = 16M\nPGA_AGGREGATE_TARGET = 3G<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>When to use:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Very specific tuning requirements<\/li>\n\n\n\n<li>You know exact optimal sizes (rare)<\/li>\n\n\n\n<li>Legacy systems<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Downtime needed:<\/strong> Changes to most SGA components require restart<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>CRITICAL RULES:<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u274c NEVER SET BOTH:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>-- WRONG - Don't mix AMM and ASMM<\/em>\nMEMORY_TARGET = 10G       <em>-- AMM<\/em>\nSGA_TARGET = 8G           <em>-- ASMM (will be ignored!)<\/em><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u2705 CORRECT COMBINATIONS:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Option A: Use ASMM (Recommended for 19c)<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SGA_TARGET = 10G\nSGA_MAX_SIZE = 12G\nPGA_AGGREGATE_TARGET = 3G\nPGA_AGGREGATE_LIMIT = 6G\nMEMORY_TARGET = 0         <em>-- Explicitly disable AMM<\/em><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Option B: Use AMM<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>MEMORY_TARGET = 13G\nMEMORY_MAX_TARGET = 16G\nSGA_TARGET = 0            <em>-- Must be 0 or not set<\/em>\nPGA_AGGREGATE_TARGET = 0  <em>-- Must be 0 or not set<\/em><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Option C: Manual<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SGA_TARGET = 0\nMEMORY_TARGET = 0\nDB_CACHE_SIZE = 6G\nSHARED_POOL_SIZE = 2G\nPGA_AGGREGATE_TARGET = 3G<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>PARAMETER CHANGE &#8211; DOWNTIME REQUIREMENTS:<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table has-small-font-size\"><table><thead><tr><th>Parameter<\/th><th>Dynamic Change?<\/th><th>Requires Restart?<\/th><th>Notes<\/th><\/tr><\/thead><tbody><tr><td><code>SGA_TARGET<\/code><\/td><td>\u2705 Yes (up to <code>SGA_MAX_SIZE<\/code>)<\/td><td>\u274c No<\/td><td>Can increase\/decrease online<\/td><\/tr><tr><td><code>SGA_MAX_SIZE<\/code><\/td><td>\u274c No<\/td><td>\u2705 Yes<\/td><td>Requires instance restart<\/td><\/tr><tr><td><code>PGA_AGGREGATE_TARGET<\/code><\/td><td>\u2705 Yes<\/td><td>\u274c No<\/td><td>Can change anytime<\/td><\/tr><tr><td><code>PGA_AGGREGATE_LIMIT<\/code><\/td><td>\u2705 Yes<\/td><td>\u274c No<\/td><td>19c feature, dynamic<\/td><\/tr><tr><td><code>MEMORY_TARGET<\/code><\/td><td>\u2705 Yes (up to <code>MEMORY_MAX_TARGET<\/code>)<\/td><td>\u274c No<\/td><td>Can change online<\/td><\/tr><tr><td><code>MEMORY_MAX_TARGET<\/code><\/td><td>\u274c No<\/td><td>\u2705 Yes<\/td><td>Requires restart<\/td><\/tr><tr><td><code>DB_CACHE_SIZE<\/code><\/td><td>\u2705 Yes (if ASMM disabled)<\/td><td>\u26a0\ufe0f Depends<\/td><td>Dynamic only in manual mode<\/td><\/tr><tr><td><code>SHARED_POOL_SIZE<\/code><\/td><td>\u2705 Yes (if ASMM disabled)<\/td><td>\u26a0\ufe0f Depends<\/td><td>Dynamic only in manual mode<\/td><\/tr><tr><td><code>LOG_BUFFER<\/code><\/td><td>\u274c No<\/td><td>\u2705 Yes<\/td><td>Static parameter<\/td><\/tr><tr><td><code>LARGE_POOL_SIZE<\/code><\/td><td>\u2705 Yes<\/td><td>\u274c No<\/td><td>Dynamic<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>How to change dynamically:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>-- Check if parameter is dynamic<\/em>\nSELECT name, value, isses_modifiable, issys_modifiable \nFROM v$parameter \nWHERE name = 'sga_target';\n\n<em>-- Change SGA_TARGET online (within SGA_MAX_SIZE limit)<\/em>\nALTER SYSTEM SET sga_target=12G SCOPE=BOTH;\n\n<em>-- To exceed SGA_MAX_SIZE, must restart<\/em>\nALTER SYSTEM SET sga_max_size=16G SCOPE=SPFILE;  <em>-- Change in SPFILE<\/em>\nSHUTDOWN IMMEDIATE;\nSTARTUP;<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>INTERVIEW QUESTIONS:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q1: Can I set both MEMORY_TARGET and SGA_TARGET?<\/strong><br><strong>A:<\/strong> No. If you set <code>MEMORY_TARGET<\/code> (AMM), you must leave <code>SGA_TARGET=0<\/code>. If you set <code>SGA_TARGET<\/code> (ASMM), you must leave <code>MEMORY_TARGET=0<\/code>. They are mutually exclusive. Setting both causes Oracle to ignore <code>SGA_TARGET<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q2: Which is better &#8211; AMM or ASMM?<\/strong><br><strong>A:<\/strong> For 19c production systems, <strong>ASMM is recommended<\/strong>. AMM has overhead and isn&#8217;t supported with huge pages on Linux. ASMM gives you better control and performance for large SGA sizes (&gt;20GB).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q3: Can I increase SGA_TARGET without downtime?<\/strong><br><strong>A:<\/strong> Yes, but only up to <code>SGA_MAX_SIZE<\/code>. If you need to go beyond <code>SGA_MAX_SIZE<\/code>, you must change <code>SGA_MAX_SIZE<\/code> in SPFILE and restart the instance.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q4: How to check current memory usage?<\/strong><br><strong>A:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>-- SGA components<\/em>\nSELECT * FROM v$sga;\nSELECT * FROM v$sgastat ORDER BY bytes DESC;\n\n<em>-- PGA usage<\/em>\nSELECT * FROM v$pgastat;\nSELECT name, value\/1024\/1024 MB FROM v$pgastat \nWHERE name IN ('total PGA allocated', 'total PGA inuse');\n\n<em>-- Memory parameters<\/em>\nSHOW PARAMETER sga\nSHOW PARAMETER pga\nSHOW PARAMETER memory<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q5: What if I set SGA_TARGET=10G but SGA_MAX_SIZE=8G?<\/strong><br><strong>A:<\/strong> Database won&#8217;t start. You&#8217;ll get error: &#8220;ORA-00844: Parameter not taking MEMORY_MAX_TARGET into account&#8221;. <code>SGA_MAX_SIZE<\/code> must be &gt;= <code>SGA_TARGET<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q6: Does changing PGA_AGGREGATE_TARGET require restart?<\/strong><br><strong>A:<\/strong> No. It&#8217;s a dynamic parameter. Change takes effect immediately for new sessions. Existing sessions adjust gradually.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q7: I increased SGA_TARGET but free memory didn&#8217;t decrease on OS level. Why?<\/strong><br><strong>A:<\/strong> Oracle allocates up to <code>SGA_MAX_SIZE<\/code> at startup (on Linux). Increasing <code>SGA_TARGET<\/code> doesn&#8217;t allocate more OS memory\u2014it just allows Oracle to use more of the already-allocated space.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q8: How to switch from AMM to ASMM?<\/strong><br><strong>A:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>-- First, note current values<\/em>\nSHOW PARAMETER memory_target\nSHOW PARAMETER sga_target\n\n<em>-- Set ASMM parameters<\/em>\nALTER SYSTEM SET memory_target=0 SCOPE=SPFILE;\nALTER SYSTEM SET sga_target=10G SCOPE=SPFILE;\nALTER SYSTEM SET sga_max_size=12G SCOPE=SPFILE;\nALTER SYSTEM SET pga_aggregate_target=3G SCOPE=SPFILE;\n\n<em>-- Restart required<\/em>\nSHUTDOWN IMMEDIATE;\nSTARTUP;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>A. SGA (System Global Area) &#8211; Shared Memory Purpose: Shared by all users and processes. Allocated at instance startup. Main Components: 1. Database Buffer Cache 2. Shared Pool a) Library Cache: Stores parsed SQL, PL\/SQL code (execution plans) b) Data Dictionary Cache (Row Cache): c) Result Cache (19c): 3. Redo Log Buffer 4. Large Pool [&hellip;]<\/p>\n","protected":false},"template":"","meta":{"googlesitekit_rrm_CAowu461DA:productID":""},"categories":[952,1241],"class_list":["post-5266","cposts","type-cposts","status-publish","hentry","category-notes","category-oracle-database-architecture"],"_links":{"self":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/cposts\/5266","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/cposts"}],"about":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/types\/cposts"}],"wp:attachment":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/media?parent=5266"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/categories?post=5266"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}