`

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 可以自行修改监控内容,对于和我一样的脚本小白有点用

    Professional Microsoft SQL Server 2008 Administration

    It is no longer unheard of to have 20-terabyte databases running on a SQL Server. SQL Server administration used to just be the job of a database administrator (DBA), but as SQL Server proliferates ...

    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...

    微软内部资料-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...

    微软内部资料-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...

    sqlserver中几种典型的等待

    早上接到一用户反馈其RDS实例非常的慢,通过观察sqlserver活动会话监视器(active monitor)的waiting tasks(类似于mysql的thread running)可以看到有10多w的等待任务,可以明确数据库现在已经出现了较大的瓶颈,紧...

    微软内部资料-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>: ...

    最完整的Toad For Oracle使用手册

    SQL Monitor 432 Toad UNIX Monitor 432 ADDM/AWR 434 Database Browser 446 Database Monitor 449 Database Probe 453 Index Monitoring 458 Instance Manager 460 Session Browser 466 SGA Trace/Optimization 483...

    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 ...

    Deploying.SharePoint.2016.1484219988

    Understand approaches to high availability, disaster recovery, patching, and ways to monitor and maintain your SharePoint 2016 deployment once it’s up and running. Who This Book Is For Anyone tasked ...

    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....

    jdk-9.0.1_doc-all 最新版

    Defines the jstatd tool for starting a daemon for the jstat tool to monitor JVM statistics remotely. jdk.localedata Provides the locale data for locales other than US locale. jdk.management Defines ...

    php.ini-development

    ;;;;;;;;... 1.... 2.... 3.... 4.... 5.... 6.... The syntax of the file is extremely simple.... Section headers (e.g.... at runtime.... There is no name validation.... (e.g.... previously set variable or directive (e.g....

Global site tag (gtag.js) - Google Analytics