您好,登錄后才能下訂單哦!
本篇文章為大家展示了Oracle調優中常用表KEEP到內存中的示例分析,內容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細介紹希望你能有所收獲。
數據遷移后性能受到影響,需要將老數據庫中keep到內存中的表在新庫中keep到內存中,使用如下方法。
新庫設置db_keep_cache_size為適當值,這個值的大小不能小于需要keep的表的大小。
查看老庫中需要keep的表信息:
select s.owner,
s.segment_name,
s.partition_name,
s.bytes / 1024 / 1024 as "size(m)"
from dba_segments s
where owner = 'XXX'
and segment_name in
(select table_name from dba_tables where owner = 'XXX' and buffer_pool='KEEP')
order by 4 desc
查詢老庫中需要keep表總大小:
select sum(s.bytes / 1024 / 1024 / 1024) as "total keep size(G)"
from dba_segments s
where segment_name in
(select table_name from dba_tables where owner = 'XXX' and buffer_pool='KEEP')
生成keep腳本:
select 'alter table XXX.'||s.segment_name||' storage(buffer_pool keep);' as "腳本"
from dba_segments s
where owner = 'XXX'
and segment_name in
(select table_name from dba_tables where owner = 'XXX' and buffer_pool='KEEP')
keep表到內存中:
select 'alter table XXX.'||s.segment_name||' cache;' as "腳本2"
from dba_segments s
where owner = 'XXX'
and segment_name in
(select table_name from dba_tables where owner = 'XXX' and buffer_pool='KEEP')
上兩個腳本整合:
select 'alter table XXX.'||s.segment_name||' storage(buffer_pool keep) cache;' as "腳本"
from dba_segments s
where owner = 'XXX'
and segment_name in
(select table_name from dba_tables where owner = 'XXX' and buffer_pool='KEEP')
上述三個腳本輸出結果放在plsql中執行即可。
附錄:與cache到內存相關的命令
--表緩存
alter table ..... storage(buffer_pool keep);
--查看哪些表被放在緩存區 但并不意味著該表已經被緩存
select table_name from dba_tables where buffer_pool='keep';
--查詢到該表是否已經被緩存
select table_name,cache,buffer_pool from user_TABLES where cache like '%Y';
--已經加入到KEEP區的表想要移出緩存,使用
alter table table_name nocache;
--查詢當前用戶下表的情況
select table_name,cache,buffer_pool from user_TABLES;
--對于普通LOB類型的segment的cache方法
alter table t2 modify lob(c2) (storage (buffer_pool keep) cache);
--取消緩存
alter table test modify lob(address) (storage (buffer_pool keep) nocache);
--查詢段
select segment_name,segment_type,buffer_pool from user_segments;
--對基于CLOB類型的對象的cache方法
alter table lob1 modify lob(c1.xmldata) (storage (buffer_pool keep) cache);
--查詢該用戶下所有表內的大字段情況
select column_name,segment_name from user_lobs;
--取消表緩存
alter table XXX storage(buffer_pool default);
ps:
查看keep空間的剩余大小:
select p.name,a.cnum_repl "total buffers",a.anum_repl "free buffers"
from x$kcbwds a, v$buffer_pool p
where a.set_id=p.LO_SETID and p.name='KEEP';
查看keep空間的大小:
select component,current_size from v$sga_dynamic_components
where component='KEEP buffer cache';
上述內容就是Oracle調優中常用表KEEP到內存中的示例分析,你們學到知識或技能了嗎?如果還想學到更多技能或者豐富自己的知識儲備,歡迎關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。