{"id":1084,"date":"2011-02-23T15:34:08","date_gmt":"2011-02-23T20:34:08","guid":{"rendered":"http:\/\/appcrawler.com\/wordpress\/?p=1084"},"modified":"2011-07-06T10:09:09","modified_gmt":"2011-07-06T15:09:09","slug":"why-pga_aggregate_target-is-not-a-hard-limit","status":"publish","type":"post","link":"http:\/\/appcrawler.com\/wordpress\/2011\/02\/23\/why-pga_aggregate_target-is-not-a-hard-limit\/","title":{"rendered":"Why PGA_AGGREGATE_TARGET is not a hard limit"},"content":{"rendered":"<p>PGA_AGGREGATE_TARGET is not a hard limit.  Lather, rinse, and repeat \ud83d\ude42<\/p>\n<p>I like to think of it as a tuning suggestion to Oracle as to how much it can allocate for things such as sorts and hash tables.  Below is a test case that shows this.<\/p>\n<pre lang=\"sql\" line=\"1\">\r\nSQL> show parameter pga\r\n\r\nNAME                                 TYPE        VALUE\r\n------------------------------------ ----------- ------------------------------\r\npga_aggregate_target                 big integer 788M\r\nSQL> declare\r\n  2    type t_array is table of varchar2(4000);\r\n  3    l_array t_array := t_array();\r\n  4    l_mem number;\r\n  5    l_spid number;\r\n  6  begin\r\n  7    for i in 1..100000 loop\r\n  8      l_array.extend(1);\r\n  9      l_array(i) := rpad('.',3900,'.');\r\n10    end loop;\r\n11    dbms_lock.sleep(5);\r\n12    select pga_alloc_mem into l_mem from v$process where addr = (select paddr from v$session where sid = sys_context('userenv','sid'));\r\n13    dbms_output.put_line((trunc(l_mem \/ 1024 \/ 1024)) || 'MB used before clearing the array.');\r\n14    l_array.delete;\r\n15    dbms_session.free_unused_user_memory();\r\n16    dbms_lock.sleep(5);\r\n17    select pga_alloc_mem into l_mem from v$process where addr = (select paddr from v$session where sid = sys_context('userenv','sid'));\r\n18    dbms_output.put_line((trunc(l_mem \/ 1024 \/ 1024)) || 'MB used after clearing the array.');\r\n19  end;\r\n20  \/\r\n1393MB used before clearing the array.\r\n699MB used after clearing the array.\r\n\r\nPL\/SQL procedure successfully completed.\r\n\r\nSQL> select trunc(pga_alloc_mem \/ 1024 \/ 1024) from v$process where addr = (select paddr from v$session where sid = sys_context('userenv','sid'));\r\n\r\nTRUNC(PGA_ALLOC_MEM\/1024\/1024)\r\n------------------------------\r\n                             4\r\n\r\nSQL>\r\n<\/pre>\n<p>Notice we allocated almost 1.4GB of memory, which almost doubled what has been configured as our target.  Nothing prevents a developer from loading up a huge array and bringing your database server to its knees&#8230;other than testing, of course \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PGA_AGGREGATE_TARGET is not a hard limit. Lather, rinse, and repeat \ud83d\ude42 I like to think of it as a tuning suggestion to Oracle as to how much it can allocate for things such as sorts and hash tables. Below is&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/appcrawler.com\/wordpress\/2011\/02\/23\/why-pga_aggregate_target-is-not-a-hard-limit\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[19,22],"tags":[],"_links":{"self":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/1084"}],"collection":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/comments?post=1084"}],"version-history":[{"count":5,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/1084\/revisions"}],"predecessor-version":[{"id":1326,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/1084\/revisions\/1326"}],"wp:attachment":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1084"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1084"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1084"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}