What is granules in Oracle Database :

Granules in oracle refers to a unit of memory allocation used for managing the SGA (System Global Area) memory structure or we can say it is a unit of contiguous virtual memory. The SGA is a shared memory region that Oracle utilizes to store data and control information for efficient database operations. Granules are dynamically allocated and managed by Oracle and the granule size is defined while starting the database instance.

The SGA is divided into multiple granules, where each granule represents a fixed-size block of memory. The size of a granule is determined by an initialization parameter, such as “DB_16K_CACHE_SIZE,” or a similar parameter specific to the Oracle version being used.

The purpose of dividing the SGA into granules is to facilitate efficient memory management and reduce contention when multiple processes or threads access the SGA concurrently. Allocating memory in granules allows Oracle to quickly allocate or deallocate memory without impacting the entire SGA. We can get the granules from two views v$SGAINFO and v$SGA_DYNAMIC_COMPONENTS.

get information of granules in oracle database

The size of granules in oracle can vary depending on the Oracle configuration and the underlying platform. In most recent versions, the default granule size is typically 16KB, although it can be adjusted to meet specific system requirements.

As per Oracle Doc, granules can be defined as below :

SGA_MAX_SIZE <= 1GB Granule size: 4 MB
1GB < SGA_MAX_SIZE <= 8GB Granule size: 16 MB
8GB < SGA_MAX_SIZE <= 16GB Granule size: 32 MB
16GB < SGA_MAX_SIZE <= 32GB Granule size: 64 MB
32GB < SGA_MAX_SIZE <= 64GB Granule size: 128 MB
64GB < SGA_MAX_SIZE <= 128GB Granule size: 256 MB
128GB < SGA_MAX_SIZE Granule size: 512 MB

We can find the granules size by issuing the below command as well :

select inst_id, ((current_size - user_specified_size) / granule_size) "Granules" from gv$sga_dynamic_components where component like 'DEFAULT buffer cache' order by 1;
What is granules in Oracle Database :

It’s important to note that the concept of granules is unique to Oracle databases and may not be relevant to other database management systems.

Leave a Reply