What is the difference between SGA_MAX_SIZE and SGA_TARGET initialization parameters in oracle database instance?
SGA_TARGET specifies the total amount of system global area (SGA) memory available to oracle SGA instance.
And when you set memory value to this parameter, oracle will automatically distribute the available memory among the SGA components, such as shared pool, Java pool, large_pool, database buffer cache, Redo log buffer and streams pool.
The SGA_MAX_SIZE parameter is the maximum allowable size to resize the SGA parameters.
If the SGA_TARGET is set to some value then the Automatic Shared Memory Management (ASMM) is enabled.
And the SGA_TARGET value can be adjusted up to the SGA_MAX_SIZE parameter, but not more than SGA_MAX_SIZE parameter value.
We can use the following SQL statements to check total SGA size and SGA_TARGET.
To check the total SGA size:
SQL> SELECT sum(value)/1024/1024/1024 "TOTAL SGA (GB)" FROM v$sga; TOTAL SGA (GB) -------------- 350 SQL>
And to check the SGA target size:
SQL> select (value/1024/1024/1024) "Size_IN_GB" from v$parameter where name = 'sga_target'; Size_IN_GB ---------- 350 SQL>
And finally to find the total usage of SGA:
SQL> select round(used.bytes /1024/1024/1024 ,2) used_GB , round(free.bytes /1024/1024/1024 ,2) free_GB 2 3 , round(tot.bytes /1024/1024/1024 ,2) total_GB 4 from (select sum(bytes) bytes 5 from v$sgastat 6 where name != 'free memory') used 7 , (select sum(bytes) bytes 8 from v$sgastat 9 where name = 'free memory') free 10 , (select sum(bytes) bytes from v$sgastat) tot ; 11 USED_GB FREE_GB TOTAL_GB ---------- ---------- ---------- 330.49 19.51 350 SQL>
NOTE: SGA_TARGET can not be greater than SGA_MAX_SIZE.