Ai
1 Star 1 Fork 0

冯际成/Oracle_SQL_Scripts

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
rac_waiting_sessions.sql 3.71 KB
一键复制 编辑 原始数据 按行查看 历史
Abdul mohammed 提交于 2016-02-06 08:58 +08:00 . Fri Feb 5 18:58:16 CST 2016
-- | PURPOSE : This script produces a report of the top sessions that have |
-- | waited (the entries at top have waited the longest) for |
-- | non-idle wait events )event column). The Oracle Server |
-- | Reference Manual can be used to further diagnose the wait event |
-- | (along with its parameters). Metalink can also be used by |
-- | supplying the event name in the search bar. |
-- | |
-- | The INST_ID column shows the instance where the session resides |
-- | and the SID is the unique identifier for the session |
-- | (gv$session). The p1, p2, and p3 columns will show event |
-- | specific information that may be important to debug the |
-- | problem. |
-- | EXAMPLE : For example, you can search Metalink by supplying the event |
-- | METALINK : name (surrounded by single quotes) as in the following example: |
-- | SEARCH : |
-- | [ 'Sync ASM rebalance' ] |
-- | NOTE : As with any code, ensure to test this script in a development |
-- | environment before attempting to run it in production. |
-- +----------------------------------------------------------------------------+
set tab off
SET PAGESIZE 9999
SET VERIFY off
COLUMN instance_name FORMAT a11 HEAD 'Instance|Name / ID'
COLUMN sid FORMAT a13 HEAD 'SID / Serial#'
COLUMN oracle_username HEAD 'Oracle|Username'
COLUMN state FORMAT a7 HEAD 'State'
COLUMN event FORMAT a25 HEAD 'Event'
COLUMN last_sql FORMAT a25 HEAD 'Last SQL'
SELECT
i.instance_name || ' (' || sw.inst_id || ')' instance_name
, sw.sid || ' / ' || s.serial# sid
, s.username oracle_username
, sw.state state
, sw.event
, sw.seconds_in_wait seconds
, sw.p1
, sw.p2
, sw.p3
, sa.sql_text last_sql
FROM
gv$session_wait sw
INNER JOIN gv$session s ON ( sw.inst_id = s.inst_id
AND
sw.sid = s.sid
)
INNER JOIN gv$sqlarea sa ON ( s.inst_id = sa.inst_id
AND
s.sql_address = sa.address
)
INNER JOIN gv$instance i ON ( s.inst_id = i.inst_id)
WHERE
sw.event NOT IN ( 'rdbms ipc message'
, 'smon timer'
, 'pmon timer'
, 'SQL*Net message from client'
, 'lock manager wait for remote message'
, 'ges remote message'
, 'gcs remote message'
, 'gcs for action'
, 'client message'
, 'pipe get'
, 'null event'
, 'PX Idle Wait'
, 'single-task message'
, 'PX Deq: Execution Msg'
, 'KXFQ: kxfqdeq - normal deqeue'
, 'listen endpoint status'
, 'slave wait'
, 'wakeup time manager'
)
and sw.seconds_in_wait > 0
ORDER BY seconds desc
/
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sapall/Oracle_SQL_Scripts.git
git@gitee.com:sapall/Oracle_SQL_Scripts.git
sapall
Oracle_SQL_Scripts
Oracle_SQL_Scripts
master

搜索帮助