PGA & UGA
Program Global Area (PGA)
The Program Global Area (PGA) is a type of memory in an Oracle database that is specific to an individual operating process or thread. It is not shared with other processes or threads on the system. Unlike the System Global Area (SGA), which is shared among multiple processes, the PGA is dedicated to a particular process.
The PGA serves as a memory heap for storing session-dependent variables required by dedicated or shared server processes in Oracle. These server processes allocate memory structures within the PGA to hold information necessary for executing SQL or PL/SQL code and processing queries.
Here’s a summary of key points about the PGA:
- Dedicated vs. Shared Server: The PGA is used in both dedicated and shared server configurations, but in either case, it remains specific to a single session or process.
- Private SQL Area: A significant part of the PGA is dedicated to the private SQL area, which stores information about parsed SQL statements and session-specific details for query execution. This includes bind variable values, query execution state information, and work areas for query processing. Each session has its own private SQL area.
- Cursor Management: Cursors are closely associated with private SQL areas, and they are used to manage SQL statements. The number of private SQL areas that a client process can allocate is limited by the OPEN_CURSORS initialization parameter. It’s essential to close open cursors that won’t be used again to free up memory.
- SQL Work Areas: PGA memory is also used for work areas, which are private allocations of memory used for memory-intensive operations such as sorting and hash joins. The size of work areas can be automatically managed by Oracle when automatic PGA memory management is enabled, or it can be manually controlled and tuned.
- Differences in Dedicated vs. Shared Servers: In dedicated server connections, both the persistent area and the run-time area for DML and DDL statements are located in the PGA. In shared server connections, some of these areas are located in the SGA, which is shared among multiple sessions.
In summary, the PGA is a dedicated memory area for session-specific data and query processing in Oracle databases. It plays a crucial role in managing memory for SQL execution, and its usage may vary depending on whether the database is configured for dedicated or shared server connections.
User Global Area (UGA)
The User Global Area (UGA) is a crucial component of Oracle Database’s memory architecture, allocated specifically for a database session. It serves as session memory, storing essential session-specific variables and information, effectively maintaining the session’s state.
Key characteristics of the UGA include:
- Session State Storage: The UGA is responsible for holding session variables, including login information and other data pertinent to the session’s operation. It acts as a repository for maintaining the current state of a session.
- PL/SQL Package State: When a session loads a PL/SQL package into memory, the UGA contains the package state. This state encompasses all the values stored in package variables at a given point in time. It changes when package subprograms modify these variables. Package variables are unique to the session and persist throughout the session’s lifetime.
- OLAP Page Pool: The UGA also accommodates the OLAP page pool, which manages OLAP data pages, similar to data blocks. This pool is allocated at the beginning of an OLAP session and released at the session’s conclusion. OLAP sessions are automatically initiated when users query dimensional objects like cubes.
- Storage Location: The UGA must be accessible to a database session for the entire duration of the session. When using shared server connections, the UGA is stored in the System Global Area (SGA) because the Program Global Area (PGA) is specific to a single process. However, in dedicated server connections, the UGA resides in the PGA.
In summary, the User Global Area (UGA) plays a pivotal role in maintaining session-specific information and state within Oracle Database. It ensures that session variables and package states are readily available for the entire duration of a user’s interaction with the database, contributing to the integrity and functionality of individual sessions.