Identify Tables & Indexes need to be pinned onto SGA:
***************************************************************************
SELECT 'alter table '
|| p.owner
|| '.'
|| p.name
|| ' storage (buffer_pool keep);'
FROM dba_tables t,
dba_segments s,
dba_hist_sqlstat a,
(SELECT DISTINCT pl.sql_id, pl.object_owner owner, pl.object_name name
FROM dba_hist_sql_plan pl
WHERE pl.operation = 'TABLE ACCESS' AND pl.options = 'FULL') p
WHERE a.sql_id = p.sql_id
AND t.owner = s.owner
AND t.table_name = s.segment_name
AND t.table_name = p.name
AND t.owner = p.owner
AND t.owner NOT IN ('SYS', 'SYSTEM')
AND t.buffer_pool <> 'KEEP'
HAVING s.blocks < 50
GROUP BY p.owner,
p.name,
t.num_rows,
s.blocks
UNION
SELECT 'alter index '
|| owner
|| '.'
|| index_name
|| ' storage (buffer_pool keep);'
FROM dba_indexes
WHERE owner || '.' || table_name IN
( SELECT p.owner || '.' || p.name
FROM dba_tables t,
dba_segments s,
dba_hist_sqlstat a,
(SELECT DISTINCT
pl.sql_id,
pl.object_owner owner,
pl.object_name name
FROM dba_hist_sql_plan pl
WHERE pl.operation = 'TABLE ACCESS'
AND pl.options = 'FULL') p
WHERE a.sql_id = p.sql_id
AND t.owner = s.owner
AND t.table_name = s.segment_name
AND t.table_name = p.name
AND t.owner = p.owner
AND t.owner NOT IN ('SYS', 'SYSTEM')
AND t.buffer_pool <> 'KEEP'
HAVING s.blocks < 50
GROUP BY p.owner,
p.name,
t.num_rows,
s.blocks);
**********************************************************************
No comments:
Post a Comment