{"id":3680,"date":"2025-05-29T12:27:30","date_gmt":"2025-05-29T12:27:30","guid":{"rendered":"https:\/\/w3buddy.com\/?post_type=cposts&#038;p=3680"},"modified":"2025-05-29T12:47:33","modified_gmt":"2025-05-29T12:47:33","slug":"program-global-area","status":"publish","type":"cposts","link":"https:\/\/w3buddy.com\/blog\/notes\/getting-started-with-oracle-dba\/program-global-area\/","title":{"rendered":"Program Global Area"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Program Global Area (PGA)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\ud83e\udde0 <strong>Introduction<\/strong><br>The <strong>Program Global Area (PGA)<\/strong> is like a private workspace for each Oracle process.<br>Unlike the SGA, which is shared by all, the PGA is <strong>nonshared<\/strong> \u2014 dedicated to a single server or background process.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Think of it like a developer having their own laptop (PGA), while the whole team shares a server (SGA).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\ud83e\udde9 <strong>What is the PGA?<\/strong><br>The <strong>PGA<\/strong> is a memory region created when a <strong>server process<\/strong> or <strong>background process<\/strong> starts and is automatically deallocated when the process ends.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It holds session-specific data and control information that <strong>only<\/strong> that process can access.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\ud83e\udde0 <strong>PGA Components (Dedicated Server Mode)<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udd39 <strong>1. SQL Work Areas<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Used during SQL execution for memory-intensive operations:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Sort Area<\/strong>: Handles sorting for <code>ORDER BY<\/code>, <code>GROUP BY<\/code>, etc.<\/li>\n\n\n\n<li><strong>Hash Area<\/strong>: Used in <strong>hash joins<\/strong> to match rows between tables<\/li>\n\n\n\n<li><strong>Bitmap Merge Area<\/strong>: Merges results from multiple <strong>bitmap index<\/strong> scans<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udd39 <strong>2. User Global Area (UGA)<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Stores <strong>session-specific<\/strong> information such as:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Login\/session variables<\/li>\n\n\n\n<li>Temporary values for packages\/procedures<\/li>\n\n\n\n<li>OLAP Pool: Caches <strong>OLAP<\/strong> (Online Analytical Processing) data pages (similar to DB blocks)<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\ud83d\udcdd In <strong>dedicated server mode<\/strong>, UGA is part of the PGA.<br>In <strong>shared server mode<\/strong>, UGA moves to the <strong>Large Pool<\/strong> (in the SGA).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udd39 <strong>3. Private SQL Area<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Each SQL statement gets its own <strong>private workspace<\/strong> to store:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Parsed SQL text<\/li>\n\n\n\n<li>Bind variable values<\/li>\n\n\n\n<li>Execution state (e.g., current row, fetch status)<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">It has two main areas:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Persistent Area<\/strong>: Stores <strong>bind variables<\/strong> (placeholder values for SQL statements)<\/li>\n\n\n\n<li><strong>Runtime Area<\/strong>: Manages state during <strong>query execution<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\ud83d\udd01 <strong>Cursors<\/strong> act as pointers to Private SQL Areas, helping the database track query execution for each session.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\ud83d\udd04 <strong>PGA in Shared Server Mode<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In <strong>shared server architecture<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Many client sessions share one <strong>server process<\/strong><\/li>\n\n\n\n<li>The <strong>UGA<\/strong> is moved to the <strong>Large Pool<\/strong> (in the SGA)<\/li>\n\n\n\n<li>The PGA is left with:<br>\u2714 SQL Work Areas<br>\u2714 Private SQL Area<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">This architecture helps scale to more users with fewer server processes, conserving memory.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\ud83d\udee0\ufe0f <strong>DBA Tip of the Day<\/strong><br>Want to reduce sorting or memory-intensive slowdowns?<br>Tune your PGA using the <code>PGA_AGGREGATE_TARGET<\/code> or <code>PGA_AGGREGATE_LIMIT<\/code> parameters.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\ud83d\udd0d Show PGA Parameters<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SHOW PARAMETER pga;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u2705 Query: View PGA Memory Statistics<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>COLUMN name FORMAT A40\nCOLUMN value FORMAT 9999999999\n\nSELECT * FROM v$pgastat;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u2705 Query: View SQL Work Area Histogram<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>COLUMN operation FORMAT A30\nCOLUMN onepass FORMAT 999999\nCOLUMN multipass FORMAT 999999\nCOLUMN optimal FORMAT 999999\nCOLUMN memory_used_in_kb FORMAT 999999999\n\nSELECT * FROM v$sql_workarea_histogram;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Program Global Area (PGA) \ud83e\udde0 IntroductionThe Program Global Area (PGA) is like a private workspace for each Oracle process.Unlike the SGA, which is shared by all, the PGA is nonshared \u2014 dedicated to a single server or background process. Think of it like a developer having their own laptop (PGA), while the whole team shares [&hellip;]<\/p>\n","protected":false},"template":"","meta":{"googlesitekit_rrm_CAowu461DA:productID":""},"categories":[960,952],"class_list":["post-3680","cposts","type-cposts","status-publish","hentry","category-getting-started-with-oracle-dba","category-notes"],"_links":{"self":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/cposts\/3680","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=3680"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/categories?post=3680"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}