性能测试Oracle消耗排查记录
作者:网络转载 发布时间:[ 2015/8/21 14:17:13 ] 推荐标签:数据库
1.耗费CPU或者是执行计划较多的sql语句的查询
SELECT T.CPU_TIME,--语句解析和执行的cpu时间
T.EXECUTIONS,--从加入缓存后的执行次数
T.ELAPSED_TIME,--语句解析和执行的时间
T.SORTS,
T.PARSE_CALLS,--软硬解析次数
T.OPTIMIZER_COST,--优化器计算的成本
T.SQL_TEXT--执行的sql语句
FROM SYS.V_$SQL T
WHERE T.OPTIMIZER_COST IS NOT NULL
AND T.EXECUTIONS > 500
ORDER BY T.OPTIMIZER_COST DESC;
2.获取耗费资源多的sql语句
select * from
(select b.username username, a.DISK_READS reads, a.EXECUTIONS exec, a.DISK_READS/decode(a.EXECUTIONS,0,1,a.EXECUTIONS) rds_exec_ratio, a.SQL_TEXT statement
from sys.v_$sqlarea a, sys.dba_users b
where a.PARSING_USER_ID = b.user_id
and (b.username = '' or b.username = '')
and a.DISK_READS >= 50 ) t
where t.rds_exec_ratio >= 1
order by t.rds_exec_ratio desc;
3.查看当前会话信息
通过plsql中的工具栏中的会话,查看当前活跃会话,通过查看会话当前执行sql,判断性能瓶颈问题
查询当前活跃会话sql:
select * from SYS.V_$SESSION t where t.STATUS='ACTIVE' and osuser='' and type='' and username=''
当前会话游标信息:
select * from v$open_cursor where sid = :sid;
当前会话sql信息:
select sql_text from v$sqltext_with_newlines where address = hextoraw(:sql_address) and hash_value = :sql_hash_value order by piece / concatenate /
当前会话耗费信息:
select names.name, stats.statistic#, stats.value from v$sesstat stats, v$statname names where stats.sid = :sid and names.Statistic# = stats.Statistic# order by stats.statistic#
当前会话锁信息:
select l.*, o.owner object_owner, o.object_Name from sys.all_objects o, v$lock l where l.sid = :sid and l.type = 'TM' and o.object_id = l.id1
根据会话查看当前sql的消耗:
SELECT T.SID,
T1.SQL_TEXT,
T1.CPU_TIME,
T1.EXECUTIONS,
T1.OPTIMIZER_COST,
T1.ELAPSED_TIME,
T1.ELAPSED_TIME / T1.EXECUTIONS AS UNIT_ELAPSED_TIME,
T1.CPU_TIME / T1.EXECUTIONS AS UNIT_CPU_TIME
FROM SYS.V$SESSION T, SYS.V$SQL T1
WHERE T.STATUS = 'ACTIVE'
AND TYPE = ''
AND USERNAME = ''
AND T1.HASH_VALUE = T.SQL_HASH_VALUE
ORDER BY T1.CPU_TIME DESC
相关推荐
更新发布
功能测试和接口测试的区别
2023/3/23 14:23:39如何写好测试用例文档
2023/3/22 16:17:39常用的选择回归测试的方式有哪些?
2022/6/14 16:14:27测试流程中需要重点把关几个过程?
2021/10/18 15:37:44性能测试的七种方法
2021/9/17 15:19:29全链路压测优化思路
2021/9/14 15:42:25性能测试流程浅谈
2021/5/28 17:25:47常见的APP性能测试指标
2021/5/8 17:01:11