`

monitor running sql

阅读更多
--running sql?
---------------------
select osuser, username, sql_text from v$session a, v$sqltext b
where a.sql_address =b.address order by address, piece;


--view run sql
---------------------
select * from v$sql

--log mode
---------------------
select b.owner,b.object_name,l.session_id,l.locked_mode
from v$locked_object l, dba_objects b
where b.object_id=l.object_id
AND l.session_id=58

--view log
---------------------
SELECT
SUBSTR(s1.username,1,12) "WAITING USER"
, SUBSTR(s1.osuser,1,8) "OS User"
, SUBSTR(TO_CHAR(w.session_id),1,5) "Sid"
, p1.spid "PID"
, SUBSTR(s2.username,1,12) "HOLDING User"
, SUBSTR(s2.osuser,1,8) "OS User"
, SUBSTR(TO_CHAR(h.session_id),1,5) "Sid"
, p2.spid "PID"
FROM
sys.v_$process p1
, sys.v_$process p2
, sys.v_$session s1
, sys.v_$session s2
, dba_locks w
, dba_locks h
WHERE
h.mode_held != 'None'
AND h.mode_held != 'Null'
AND w.mode_requested != 'None'
AND w.lock_type (+) = h.lock_type
AND w.lock_id1 (+) = h.lock_id1
AND w.lock_id2 (+) = h.lock_id2
AND w.session_id = s1.sid (+)
AND h.session_id = s2.sid (+)
AND s1.paddr = p1.addr (+)
AND s2.paddr = p2.addr (+)
分享到:
评论

相关推荐

    DeadlockDetector 无限使用版

    With SQL Deadlock Detector, you can: Monitor and detect long-running locks and deadlocks 24/7 Identify blocking SQL code, locked objects and deadlock victims with pinpoint accuracy Accelerate system ...

    SQL Server 2012 Query Performance Tuning(Apress,3ed,2012)

    Queries not running fast enough? Tired of the phone calls from frustrated users? Grant Fritchey's book SQL Server 2012 Query Performance Tuning is the answer to your SQL Server query performance ...

    SQL Server 2017 Query Performance Tuning 5th Edition

    If your queries are not running fast enough and you’re tired of phone calls from frustrated users, then this book is the answer to your performance problems. SQL Server 2017 Query Performance ...

    mysqlMonitor.rar

    mysql 5.7.x 监控脚本,监控内容包括Queries,Com_commit,Com_rollback,Threads_connected,Threads_running 可以自行修改监控内容,对于和我一样的脚本小白有点用

    Pro.SQL.Server.Always.On.Availability.Groups.1484220706.epub

    The goal is always to have your SQL Server databases up and running whenever you need them, rain or shine, disaster or otherwise. With a focus on real-world experiences and war stories, authors Uttam...

    How I Monitor WAITS to help tune long running queries

    尽管我们倾向于在单一SQL语句中完成所有联接操作,但当需要优化这些查询时,确定哪些部分真正需要调优则成为一项挑战。使用`EXPLAIN PLAN`可以帮助我们了解联接顺序、涉及的索引及其他查询操作,但如果能进一步找出...

    微软内部资料-SQL性能优化2

     For each hypothesis generated, identify at least two other non-System Monitor pieces of information that would help to confirm or reject your hypothesis.  Identify at least five counters for each...

    Troubleshooting Performance Problems in SQL Server 2005.doc

    本文档旨在提供一个逐步的指南,帮助管理员诊断并解决这些问题,主要利用的是SQL Server Profiler、System Monitor(Perfmon)以及SQL Server 2005中的新特性——动态管理视图。 **Introduction** 引入部分指出,...

    微软内部资料-SQL性能优化3

    An intent lock indicates that SQL Server wants to acquire a shared (S) lock or exclusive (X) lock on some of the resources lower down in the hierarchy. For example, a shared intent lock placed at the ...

    oracle DBA日常脚本

    ..........\Jobs_Running.sql ..........\Latches.sql ..........\Latch_Hit_Ratios.sql ..........\Latch_Holders.sql ..........\Library_Cache.sql ..........\License.sql ..........\Locked_Objects.sql...

    微软内部资料-SQL性能优化5

    In a nonclustered index, the leaf level contains each index key, plus a bookmark that tells SQL Server where to find the data row corresponding to the key in the index. A bookmark can take one of two ...

    ora分析脚本

    - longops: run progression monitor - sessions: currently open sessions - stack <os_pid> get process stack using oradebug - cursors [all] <match_str>: [all] parsed cursors - sharing <sql_id>: ...

    Docker on Windows.pdf

    What You Will LearnComprehend key Docker concepts: images, containers, registries, and swarmsRun Docker on Windows 10, Windows Server 2016, and in the cloudDeploy and monitor distributed solutions ...

    MySQL Event Scheduler(事件调度器)

    WHERE VARIABLE_NAME = 'SLAVE_RUNNING'; IF ('ON' != @SLAVE_STATUS) THEN SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 0; SLAVE START; END IF; end; // delimiter ; ``` 2. **创建事件**:接下来,创建一个...

    Raspberry Pi Zero Cookbook

    Edward Snajder takes on the challenges of performance, optimization, scalability, and portability for PostgreSQL, Oracle, SQL Server, and MySQL DB engines for the databases behind the Jive platform....

    最完整的Toad For Oracle使用手册

    - **SQL Monitor**:介绍了SQL监视器的使用方法。 - **Toad UNIX Monitor**:讲解了UNIX监视器的使用方法。 - **ADDM/AWR**:提供了ADDM/AWR的使用方法。 - **Database Browser**:介绍了数据库浏览器的功能。 - **...

    Lighttpd By Andre Bogus

    It serves as a fast-paced resource to help users get up and running with Lighttpd as quickly and securely as possible. #### Overview of Lighttpd Lighttpd (pronounced "lighty") is a high-performance...

    Oracle Database 10g: The Top 20 Features for DBAs

    It helps in managing the rollback segment space efficiently by alerting DBAs when space is running low, preventing transaction failures due to lack of rollback space. **Benefits:** - Ensures ...

Global site tag (gtag.js) - Google Analytics