By wanhang 发表于 2006-1-12 17:36:00 | |
希望整理一个监控oracle性能的常用sql集锦,希望大家不断更加: 1. 监控事例的等待 select event,sum(decode(wait_Time,0,0,1)) "Prev", 2. 回滚段的争用情况 select name, waits, gets, waits/gets "Ratio" 3. 监控表空间的 I/O 比例 select df.tablespace_name name,df.file_name "file",f.phyrds pyr, 4. 监控文件系统的 I/O 比例 select substr(a.file#,1,2) "#", substr(a.name,1,30) "Name", 5.在某个用户下找所有的索引 select user_indexes.table_name, user_indexes.index_name,uniqueness, column_name 6. 监控 SGA 的命中率 select a.value + b.value "logical_reads", c.value "phys_reads", 7. 监控 SGA 中字典缓冲区的命中率 select parameter, gets,Getmisses , getmisses/(gets+getmisses)*100 "miss ratio", 8. 监控 SGA 中共享缓存区的命中率,应该小于1% select sum(pins) "Total Pins", sum(reloads) "Total Reloads", select sum(pinhits-reloads)/sum(pins) "hit radio",sum(reloads)/sum(pins) "reload percent" 9. 显示所有数据库对象的类别和大小 select count(name) num_instances ,type ,sum(source_size) source_size , 10. 监控 SGA 中重做日志缓存区的命中率,应该小于1% SELECT name, gets, misses, immediate_gets, immediate_misses, 11. 监控内存和硬盘的排序比率,最好使它小于 .10,增加 sort_area_size SELECT name, value FROM v$sysstat WHERE name IN ('sorts (memory)', 'sorts (disk)');
SELECT osuser, username, sql_text from v$session a, v$sqltext b 13. 监控字典缓冲区 SELECT (SUM(PINS - RELOADS)) / SUM(PINS) "LIB CACHE" FROM V$LIBRARYCACHE; 后者除以前者,此比率小于1%,接近0%为好。 SELECT SUM(GETS) "DICTIONARY GETS",SUM(GETMISSES) "DICTIONARY CACHE GET MISSES" 14. 找ORACLE字符集 select * from sys.props$ where name='NLS_CHARACTERSET'; 15. 监控 MTS select busy/(busy+idle) "shared servers busy" from v$dispatcher; 此值大于0.5时,参数需加大 select sum(wait)/sum(totalq) "dispatcher waits" from v$queue where type='dispatcher'; servers_highwater接近mts_max_servers时,参数需加大 16. 碎片程度 select tablespace_name,count(tablespace_name) from dba_free_space group by tablespace_name alter tablespace name coalesce; create or replace view ts_blocks_v as select * from ts_blocks_v; select tablespace_name,sum(bytes),max(bytes),count(block_id) from dba_free_space 查看碎片程度高的表 SELECT segment_name table_name , COUNT(*) extents 17. 表、索引的存储情况检查 select segment_name,sum(bytes),count(*) ext_quan from dba_extents where select segment_name,count(*) from dba_extents where segment_type='INDEX' and owner='&owner' 18、找使用CPU多的用户session 12是cpu used by this session select a.sid,spid,status,substr(a.program,1,40) prog,a.terminal,osuser,value/60/100 value | |
|
监控数据库性能的SQL
最新推荐文章于 2021-04-14 09:44:46 发布