– 查詢實時執行的語句,etime單位是秒 3867
select 『ps -ef|grep 』 || spid ps,
/* 『alter system kill session 『』』||b.sid||』, 『||b.serial#||』』』 immediate;』 kill_session,/
b.inst_id,
b.sid,
b.serial#,
b.username,
a.sql_id,
b.event,
/round(b.last_call_et / 3600) 「ses_t(小時)」,/
trunc(((a.elapsed_time / decode(executions, 0, 1, executions)) /
1000000),
2) 「etime」,
round(a.buffer_gets / decode(a.executions, 0, 1, a.executions)) per_bu,
a.executions,
a.sql_fulltext fullsql,
a.sql_text,
a.disk_reads,
a.buffer_gets,
b.osuser,
b.machine,
b.program,
a.module,
a.cpu_time,
a.last_load_time,
a.last_active_time
from **sql
area
a,gv
sqlarea a, **
sqlare
aa,g
vsession b, **$process p
where executions >= 0
and b.status = 『active』
and a.hash_value = b.sql_hash_value
and a.sql_id = b.sql_id
and b.paddr = p.addr
/ and b.username=『system』
and b.event=『asm file metadata operation』*/
order by (cpu_time / decode(executions, 0, 1, executions)) desc,
a.buffer_gets desc,
a.executions desc,
a.sql_id;
select t.blocking_session,t.* from **$session t where t.blocking_session is not null;
–blocking_session 就是鎖,在 session 檢視狀態就可以知道是什麼情況引起的。
–alter system kill session 『sid,serial#』 immediate
select a.type,a.owner,b.sid,b.serial#,b.osuser,b.machine,b.program,b.module
from dba_ddl_locks a,v$session b where a.session_id = b.sid and a.name = 『summary_spc_pkg』;
– 檢視表空間
select tablespace_name ,sum(bytes)/1024/1024 from dba_free_space group by tablespace_name;
select tablespace_name ,sum(bytes)/1024/1024 from dba_data_files group by tablespace_name;
2020-08-18 08:44
select 『alter system disconnect session 『』』||s.sid||』, 『||s.serial#||』』』 immediate;』 kill_session,
s.inst_id,s.event, s.last_call_et, a.sql_text, s.machine, s.osuser,
s.program, s.module, s.action, s.username, a.sql_id, a.child_number, s.logon_time,
s.blocking_session,s.blocking_instance,s.service_name,
a.sql_fulltext
from **ses
sion
s,gv
session s,**
sessio
ns,g
vsql a
where s.sql_id = a.sql_id(+)
and s.sql_child_number = a.child_number(+)
and s.status = 『active』
– and s.type = 『user』
and s.username <> 『sys』
– and s.username =『cdh_query』
and s.last_call_et > 10
– and s.event=『enq: tx - row lock contention』
and s.inst_id= a.inst_id
order by s.last_call_et desc;
知道堵塞別人的sid後,檢視其session,查出serial#
select * from **$session where sid=2852 and inst_id=2
然後去對應的例項上,alter system disconnect session 『sid,serial#』 immediate;
–檢視當前db鎖的表
select s.sid,
s.serial#,
lo.oracle_username,
lo.os_user_name,
ao.object_name as table_locked_name,
s.username,
s.schemaname,
s.osuser,
s.process,
s.machine,
s.terminal,
lo.locked_mode
from vloc
kedo
bjec
tlo,
allo
bjec
tsao
,v
locked_object lo, all_objects ao, v
locked
obj
ectl
o,al
lob
ject
sao,
vsession s
where ao.object_id = lo.object_id
and lo.session_id = s.sid
– and lo.oracle_username =『rpt』
order by s.sid asc;
–alter system kill session 『sid,serial#』 immediate
–user表空間點檢
select a.tablespace_name,a.total - b.free as used, a.total, b.free as free_m,
round(b.free * 100 / a.total, 2) as free_pct
from (select tablespace_name, sum(bytes) / 1048576 as total
from dba_data_files
group by tablespace_name) a left join
(select tablespace_name, sum(bytes) / 1048576 as free
from dba_free_space
group by tablespace_name) b
on a.tablespace_name = b.tablespace_name
order by 5;
select * from dba_tablespace_usage_metrics;
檢視Mysql實時執行的Sql語句
最近給客戶開發了基於 asp.net mvc5 mysql ef的專案,但是在ef裡無法看到mysql執行的語句 之前也找到一些監控mysql的軟體但一直沒有用起來,現在又遇到了問題即在ef裡mysal的查詢沒有結果而在mysql裡沒有問題 因為不知道ef生成的mysql語句所以不知道是不是sql的...
檢視Mysql實時執行的Sql語句
很簡單即開啟mysql的log功能,那麼mysql的執行語句都會寫到log檔案裡 然後通過baretail這個專門檢視log檔案的工具即可實時檢視mysql生成的語句了 1.進入mysql 2.啟用log功能 general log on show variables like general lo...
監控mysql實時執行sql
最近專案公升級讀寫分離,但是在區分資料來源的時候,讀的資料來源總是帶事務,這樣不符合我們既定的需求,一方面讀操作不需要加事務,另一方面加事務會增加系統負載,只有檢查 監控 開始加的事務 這樣就要實時看到我們執行的sql 首先坐下mysql庫的預設配置修改 1 啟用log功能 general log ...