设为首页 加入收藏

TOP

Oracle 12C 新特性:限制PGA使用内存的大小(一)
2017-01-02 08:14:46 】 浏览:280
Tags:Oracle 12C 特性 限制 PGA 使用 内存 大小

SQL> select * from v$version;

BANNER CON_ID
-------------------------------------------------------------------------------- ----------
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production 0
PL/SQL Release 12.1.0.2.0 - Production 0
CORE 12.1.0.2.0 Production 0
TNS for Linux: Version 12.1.0.2.0 - Production 0
NLSRTL Version 12.1.0.2.0 - Production 0


查看PGA_AGGREGATE_LIMIT参数值大小为2G
SQL> show parameter pga

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
pga_aggregate_limit big integer 2G
pga_aggregate_target big integer 250M


创建测试用户


SQL> alter session set container=pdb_orcl;

Session altered.

SQL> create user zx identified by zx;

User created.

SQL> grant dba to zx;

Grant succeeded.

SQL> conn zx/zx@pdb_orcl
Connected.


创建一个包用于演示占用PGA
SQL> create or replace package demo_pkg
2 as
3 type array is table of char(2000) index by binary_integer;
4 g_data array;
5 end;
6 /

Package created.


查看当前会话sid和使用PGA内存情况
SQL> select userenv('sid') from dual;

USERENV('SID')
--------------
22
--当前会话sid为22
SQL> select a.name, to_char(b.value, '999,999,999') bytes,
2 to_char(round(b.value/1024/1024,1), '99,999.9' ) mbytes
3 from v$statname a, v$mystat b
4 where a.statistic# = b.statistic#
5 and a.name like '%ga memory%';

NAME BYTES MBYTES
---------------------------------------------------------------- ------------ ---------
session uga memory 2,301,312 2.2
session uga memory max 2,424,824 2.3
session pga memory 3,715,176 3.5
session pga memory max 3,715,176 3.5
--当前会话使用PGA内存为3.5MB


执行前面创建的包,查看PGA内存使用情况
--循环执行200000次查看PGA内存使用情况
SQL> begin
2 for i in 1 .. 200000
3 loop
4 demo_pkg.g_data(i) := 'x';
5 end loop;
6 end;
7 /

PL/SQL procedure successfully completed.

SQL> select a.name, to_char(b.value, '999,999,999') bytes,
2 to_char(round(b.value/1024/1024,1), '99,999.9' ) mbytes
3 from v$statname a, v$mystat b
4 where a.statistic# = b.statistic#
5 and a.name like '%ga memory%';

NAME BYTES MBYTES
---------------------------------------------------------------- ------------ ---------
session uga memory 470,213,072 448.4
session uga memory max 470,213,072 448.4
session pga memory 471,773,288 449.9
session pga memory max 471,773,288 449.9
--共使用449MB内存,可以算出循环执行200000*5次占用的PGA就会超过设置的2G
SQL> begin
2 for i in 1 .. 1000000
3 loop
4 demo_pkg.g_data(i) := 'x';
5 end loop;
6 end;
7 /
begin
*
ERROR at line 1:
ORA-04036: PGA memory used by the instance exceeds PGA_AGGREGATE_LIMIT
--报错ORA-4036超过了PGA_AGGREGATE_LIMIT设置的2G


调整PGA_AGGREGATE_LIMIT为4G后再次执行报错的过程,就没有问题了
SQL> conn / as sysdba
Connected.
SQL> alter system set PGA_AGGREGATE_LIMIT=4G;

System altered.

SQL> conn zx/zx@pdb_orcl
Connected.
SQL> begin
2 for i in 1 .. 1000000
3 loop
4 demo_pkg.g_data(i) := 'x';
5 end loop;
6 end;
7 /

PL/SQL procedure successfully completed.

SQL> show parameter

首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Oracle 11.2.0.3升级到11.2.0.4报.. 下一篇Oracle 密码文件与用户密码的关系

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目