oracle sga相關

chuanzhongdu1發表於2011-10-12

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 parameter parallel_threads_per_cpu

批量更新表並行度

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

可以看到所以的alter語句,在plsql develop中拷貝執行


相關文章