博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

锁优化

Posted on 2020-08-31 22:02  linFen  阅读(113)  评论(0编辑  收藏  举报


select s.username,l.object_id, l.session_id,s.serial#, s.lockwait,s.status,s.machine,s.program
from v$session s,v$locked_object l where s.sid = l.session_id


select b.sid,a.sql_text,a.*,b.* from v$sql a
inner join (select sql_hash_value, PLSQL_OBJECT_ID,sid from v$session where sid in (select session_id from v$locked_object)) b
on a.hash_value=sql_hash_value

select
ss.snap_id,
ss.instance_number node,
begin_interval_time,
sql_id,
plan_hash_value,
nvl(executions_delta, 0) execs,
(elapsed_time_delta /
decode(nvl(executions_delta, 0), 0, 1, executions_delta)) / 1000000 avg_etime,
(buffer_gets_delta /
decode(nvl(buffer_gets_delta, 0), 0, 1, executions_delta)) avg_lio
from DBA_HIST_SQLSTAT S, DBA_HIST_SNAPSHOT SS
where sql_id = ' '
and ss.snap_id = S.snap_id
and ss.instance_number = S.instance_number
and executions_delta > 0
order by 1, 2, 3

 

select b.sid,a.sql_text,
a.SHARABLE_MEM "占用的共享内存大小",
a.PERSISTENT_MEM "生命期内的固定内存大小",
a.RUNTIME_MEM "执行期内的固定内存大小",
a.SORTS "完成的排序数",
a.LOADED_VERSIONS "显示上下文堆是否载入",
a.OPEN_VERSIONS "显示子游标是否被锁",
a.USERS_OPENING "执行语句的用户数",
a.FETCHES "SQL语句的fetch数。",
a.EXECUTIONS "自它被载入缓存库后的执行次数",
a.USERS_EXECUTING "执行语句的用户数",
a.LOADS "对象被载入过的次数",
a.FIRST_LOAD_TIME "初次载入时间",
a.INVALIDATIONS "无效的次数",
a.PARSE_CALLS "解析调用次数",
a.DISK_READS "读磁盘次数",
a.BUFFER_GETS "读缓存区次数",
a.ROWS_PROCESSED "解析SQL语句返回的总列数",
a.COMMAND_TYPE "命令类型代号",
a.OPTIMIZER_MODE "SQL语句的优化器模型",
a.OPTIMIZER_COST "优化器给出的本次查询成本",
a.PARSING_USER_ID "第一个解析的用户ID",
a.PARSING_SCHEMA_ID "第一个解析的计划ID",
a.KEPT_VERSIONS "常驻内存",
a.ADDRESS "当前游标父句柄地址",
a.TYPE_CHK_HEAP "当前堆类型检查说明",
a.HASH_VALUE "缓存库中父语句的Hash值",
a.PLAN_HASH_VALUE "数值表示的执行计划。",
a.CHILD_NUMBER "子游标数量",
a.MODULE "模块名称",
a.ACTION "动作名称",
a.SERIALIZABLE_ABORTS "事务未能序列化次数",
a.OUTLINE_CATEGORY "各类",
a.CPU_TIME "CPU使用时间",
a.ELAPSED_TIME "等消耗时间",
a.OUTLINE_SID


from v$sql a
inner join (select sql_hash_value, PLSQL_OBJECT_ID,sid from v$session where sid in (select session_id from v$locked_object)) b
on a.hash_value=sql_hash_value