`

oracle sga相关

 
阅读更多

oracle主要影响性能的内存:

 

  • Shared pool

  • Large pool

  • Java pool

  • Buffer cache

  • Streams pool size

  • Log buffer

  • Process-private memory, such as memory used for sorting and hash joins

    share pool

    存放不同的数据类型,如plsql块和sql语句,字典数据

    优点:
    减少sql语句解析开销
    减少资源锁定
    减少内存需求
    减少io,字典保存在此。

    large pool

    不是LRU的,不会把老的数据移除。
    应用并行查询,并行查询用共享池保存并行查询信息
    恢复管理用共享池保存备份的信息
    共享服务用共享池保存每个session信息

     

    java pool

    主要用于JAVA语言的开发

    buffer cache

    作用保存从磁盘读的block

    buffer由keep pool,recycle pool,default pool组成

    keep pool常用小表,recycle pool不常使用的大段,default pool 上述两个不符放在这里。

    修改表的保存池 alter table table_name storage(buffer_pool keep);


     

自动共享内存管理

 

设置SGA_TARGET为非零,STATISTICS_LEVEL为TYPICAL或者ALL启动自动共享内存。

alter system set sga_target=500m scope=both statistics=typical;

一般情况下sga_target<=sga_max_size;

注意sga target+pga_target=memory_target或者memory_target不能小于之和,这样oracle启动时会报错。

解决方式

sqlplus / as sysdba;

通过spfile创建pfile;

create pfile ='/home/oracle/initora11g.ora' from spfile;

修改memory_target或者sga_target值

创建spfile

create spfile from pfile = '/home/oracle/initora11g.ora';

starup重启完成


设定cursor_sharing

如果该参数设置为similar,那么如果在shared pool中无法找到exact statement的存在的时候,就会在shared pool进行一次新的查找,就是查找和当前要解析的语句是否是similar statement的语句。这里需要对similar statement进行解释,similar statement就是除了value of some literal不同的语句,别的地方都相同的语句。比如下面:

select * from a where a=1;
select * from a where a=2;

当cursor_sharing设置为similar时,如果在shared pool中查找到这样的语句,就会做下一步的检查,看shared pool中缓存的这个语句的execution plan是否适合当前解析的语句,如果适合,就会使用shared pool的语句,而不去做hard parse

alter system set cursor_sharing=similar scope=both;


设定sequence的缓存数量

alter sequence seq_name cache=value;

设置表的并行度

select table_name,degree from dba_tables;

其中degree就是表的并行度

出了数值外degree还有值default

Default = parallel_threads_per_cpu * cpu_count

alter table xxx parallel (degree default);

parallel_threads_per_cpu查看 show parameterparallel_threads_per_cpu

批量更新表并行度

select 'alter table '||user_tables||' parallel(degree 64);' from user_tables;

可以看到所以的alter语句,在plsql develop中拷贝执行


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics