<jsp:directive.page pageEncoding="UTF-8" />
select 
	decode(sign(a.ratio - 0.9 ),1,
--	'　　　バッファキャッシュのヒット率はOKです。',
--	'警告　DB_BLOCK_BUFFERS を増やしましょう。')
	'{@LBL.ORAM0025.OK}',
	'{@LBL.ORAM0025.NG}')
	"MESSAGE",-sign(a.ratio - 0.9 ) FLAG ,
	to_char(a.ratio*100,'900.99') ratio, 'buffer cache hit ratio' "Check Item"
from ( select 1-p.value / (l1.value + l2.value) ratio
		from v$sysstat p, v$sysstat l1, v$sysstat l2
		where p.name  = 'physical reads'
		and   l1.name = 'db block gets'
		and   l2.name = 'consistent gets' ) a
union
select 
	decode(sign(a.ratio - 0.01 ),1,
--	'警告　DB_BLOCK_BUFFERSを増やしましょう。',
--	'　　　DB_BLOCK_BUFFERSを増やす必要はありません。')
	'{@LBL.ORAM0026.NG}',
	'{@LBL.ORAM0026.OK}')
	"MESSAGE",sign(a.ratio - 0.01 ) FLAG ,
	to_char(a.ratio*100,'900.99') ratio, 'cache buf latch miss'
from ( select misses / 
			decode(gets,0,1,gets) ratio
		from v$latch
		where name = 'cache buffers chains' ) a
union
select 
	decode(sign(a.ratio - 0.01 ),1,
--	'警告　DB_BLOCK_BUFFERSを増やしましょう。',
--	'　　　DB_BLOCK_BUFFERSを増やす必要はありません。')
	'{@LBL.ORAM0027.NG}',
	'{@LBL.ORAM0027.OK}')
	"MESSAGE",sign(a.ratio - 0.01 ) FLAG ,
	to_char(a.ratio*100,'900.99') ratio, 'cache buf immed chains'
from ( select immediate_misses / 
			decode(immediate_gets,0,1,immediate_gets) ratio
		from v$latch
		where name = 'cache buffers chains' ) a
union
select 
	decode(sign(a.ratio - 0.01 ),1,
--	'警告　DB_BLOCK_BUFFERSを増やしましょう。',
--	'　　　DB_BLOCK_BUFFERSを増やす必要はありません。')
	'{@LBL.ORAM0028.NG}',
	'{@LBL.ORAM0028.OK}')
	"MESSAGE",sign(a.ratio - 0.01 ) FLAG ,
	to_char(a.ratio*100,'900.99') ratio, 'cache buf LRU latch miss'
from ( select misses / 
			decode(gets,0,1,gets) ratio
		from v$latch
		where name = 'cache buffers lru chain' ) a
union
select 
	decode(sign(a.ratio - 0.01 ),1,
--	'警告　DB_BLOCK_BUFFERSを増やしましょう。',
--	'　　　DB_BLOCK_BUFFERSを増やす必要はありません。')
	'{@LBL.ORAM0029.NG}',
	'{@LBL.ORAM0029.OK}')
	"MESSAGE",sign(a.ratio - 0.01 ) FLAG ,
	to_char(a.ratio*100,'900.99') ratio, 'cache buf LRU immed chains'
from ( select immediate_misses / 
			decode(immediate_gets,0,1,immediate_gets) ratio
		from v$latch
		where name = 'cache buffers lru chain' ) a
union
select 
	decode(sign(a.ratio - 0.01 ),1,
--	'警告　アクティブなテーブルのフリーリストを増やしましょう。',
--	'　　　フリーリストの競合は起きていません。')
	'{@LBL.ORAM0030.NG}',
	'{@LBL.ORAM0030.OK}')
	"MESSAGE",sign(a.ratio - 0.01 ) FLAG ,
	to_char(a.ratio*100,'900.99') ratio, 'free list wait ratio'
from ( select w.count / l.total ratio
		from v$waitstat w,
			( select sum(value) total
				from v$sysstat
				where name IN ('db block gets',
								'consistent gets')) l
		where w.class = 'free list' ) a
union
select 
	decode(sign(a.ratio - 0.01 ),1,
--	'警告　出来るだけバインド変数を使いましょう。',
--	'　　　ライブラリキャッシュラッチの競合は起きていません。')
	'{@LBL.ORAM0031.NG}',
	'{@LBL.ORAM0031.OK}')
	"MESSAGE",sign(a.ratio - 0.01 ) FLAG ,
	to_char(a.ratio*100,'900.99') ratio, 'lib cache latch miss'
from ( select misses / 
			decode(gets,0,1,gets) ratio
		from v$latch
		where name = 'library cache' ) a
union
select 
	decode(sign(a.ratio - 0.01 ),1,
--	'警告　出来るだけバインド変数を使いましょう。',
--	'　　　ライブラリキャッシュラッチの競合は起きていません。')
	'{@LBL.ORAM0032.NG}',
	'{@LBL.ORAM0032.OK}')
	"MESSAGE",sign(a.ratio - 0.01 ) FLAG ,
	to_char(a.ratio*100,'900.99') ratio, 'lib cache immed latch miss'
from ( select immediate_misses / 
			decode(immediate_gets,0,1,immediate_gets) ratio
		from v$latch
		where name = 'library cache' ) a
union
select 
	decode(sign(a.ratio - 0.99),1,
--	'　　　ライブラリキャッシュのヒット率は十分です。',
--	'警告　SHARED_POOL_SIZE を増やしましょう。')
	'{@LBL.ORAM0033.OK}',
	'{@LBL.ORAM0033.NG}')
	"MESSAGE",-sign(a.ratio - 0.99 ) FLAG ,
	to_char(a.ratio*100,'900.99') ratio, 'library cache hit ratio'
from ( select sum( pins - reloads) / sum( pins ) ratio
		from v$librarycache ) a
union
select 
	decode(sign(a.ratio - 0.95),1,
--	'　　　SORT_AREA_SIZE は十分です。',
--	'警告　SORT_AREA_SIZE を増やしましょう。')
	'{@LBL.ORAM0034.OK}',
	'{@LBL.ORAM0034.NG}')
	"MESSAGE",-sign(a.ratio - 0.95 ) FLAG ,
	to_char(a.ratio*100,'900.99') ratio, 'memory sort ratio'
from ( select m.value / ( m.value + d.value ) ratio
		from v$sysstat m, v$sysstat d
		where m.name = 'sorts (memory)'
		and   d.name = 'sorts (disk)' ) a
union
select 
	decode(sign(a.ratio - 0.01 ),1,
--	'警告　LOG_SMALL_ENTRY_MAX_SIZEを減らしましょう。',
--	'　　　LOG_SMALL_ENTRY_MAX_SIZEを減らす必要はありません。')
	'{@LBL.ORAM0035.NG}',
	'{@LBL.ORAM0035.OK}')
	"MESSAGE",sign(a.ratio - 0.01 ) FLAG ,
	to_char(a.ratio*100,'900.99') ratio, 'redo alloc wait latch miss'
from ( select misses / 
			decode(gets,0,1,gets) ratio
		from v$latch
		where name = 'redo allocation' ) a
union
select 
	decode(sign(a.ratio - 0.01 ),1,
--	'警告　LOG_SMALL_ENTRY_MAX_SIZEを減らしましょう。',
--	'　　　LOG_SMALL_ENTRY_MAX_SIZEを減らす必要はありません。')
	'{@LBL.ORAM0036.NG}',
	'{@LBL.ORAM0036.OK}')
	"MESSAGE",sign(a.ratio - 0.01 ) FLAG ,
	to_char(a.ratio*100,'900.99') ratio, 'redo alloc immed latch miss'
from ( select immediate_misses / 
			decode(immediate_gets,0,1,immediate_gets) ratio
		from v$latch
		where name = 'redo allocation' ) a
union
select 
	decode(sign(a.ratio - 0.01 ),1,
--	'警告　LOG_SIMULTANEOUS_COPIESを増やしましょう。',
--	'　　　LOG_SIMULTANEOUS_COPIESを増やす必要はありません。')
	'{@LBL.ORAM0037.NG}',
	'{@LBL.ORAM0037.OK}')
	"MESSAGE",sign(a.ratio - 0.01 ) FLAG ,
	to_char(a.ratio*100,'900.99') ratio, 'redo copy wait latch miss'
from ( select misses / 
			decode(gets,0,1,gets) ratio
		from v$latch
		where name = 'redo copy' ) a
union
select 
	decode(sign(a.ratio - 0.01 ),1,
--	'警告　LOG_SIMULTANEOUS_COPIESを増やしましょう。',
--	'　　　LOG_SIMULTANEOUS_COPIESを増やす必要はありません。')
	'{@LBL.ORAM0038.NG}',
	'{@LBL.ORAM0038.OK}')
	"MESSAGE",sign(a.ratio - 0.01 ) FLAG ,
	to_char(a.ratio*100,'900.99') ratio, 'redo copy immed latch miss'
from ( select immediate_misses / 
			decode(immediate_gets,0,1,immediate_gets) ratio
		from v$latch
		where name = 'redo copy' ) a
union
select 
	decode(sign(a.ratio - 0.01),1,
--	'警告　LOG_BUFFER を増やしましょう。',
--	'　　　LOG_BUFFER は十分です。')
	'{@LBL.ORAM0039.NG}',
	'{@LBL.ORAM0039.OK}')
	"MESSAGE",sign(a.ratio - 0.01 ) FLAG ,
	to_char(a.ratio*100,'900.99') ratio, 'redo space wait ratio'
from ( select r.value / w.value ratio
		from v$sysstat r, v$sysstat w
		where r.name = 'redo log space requests'
		and   w.name = 'redo writes' ) a
union
select 
	decode(sign(a.ratio - 0.95),1,
--	'　　　ディクショナリキャッシュは十分です。',
--	'警告　SHARED_POOL_SIZE を増やしましょう。')
	'{@LBL.ORAM0040.OK}',
	'{@LBL.ORAM0040.NG}')
	"MESSAGE",-sign(a.ratio - 0.95 ) FLAG ,
	to_char(a.ratio*100,'900.99') ratio, 'row cache hit ratio'
from ( select sum( gets - getmisses ) / sum( gets ) ratio
		from v$rowcache ) a
union
select 
	decode(sign(a.ratio - 0.1 ),1,
--	'警告　テーブル全走査の割合が高すぎます。',
--	'　　　テーブル全走査の割合は適切です。')
	'{@LBL.ORAM0041.NG}',
	'{@LBL.ORAM0041.OK}')
	"MESSAGE",sign(a.ratio - 0.1 ) FLAG ,
	to_char(a.ratio*100,'900.99') ratio, 'table full scan ratio'
from ( select l.value / (l.value + s.value) ratio
		from v$sysstat l, v$sysstat s
		where l.name = 'table scans (long tables)'
		and   s.name = 'table scans (short tables)' ) a
union
select 
	decode(sign(a.ratio - 0.01 ),1,
--	'警告　ロールバックセグメントを増やしましょう。',
--	'　　　ロールバックセグメントの競合は起きていません。')
	'{@LBL.ORAM0042.NG}',
	'{@LBL.ORAM0042.OK}')
	"MESSAGE",sign(a.ratio - 0.01 ) FLAG ,
	to_char(a.ratio*100,'900.99') ratio,class
from ( select w.class,w.count / l.total ratio
		from v$waitstat w,
			( select sum(value) total
				from v$sysstat
				where name IN ('db block gets',
								'consistent gets')) l
		where w.class like '%undo%' ) a
order by 4
