행위

"모니터링 SQL"의 두 판 사이의 차이

DB CAFE

(리스너 트레이스)
(리스너 트레이스)
95번째 줄: 95번째 줄:
  
 
</source>
 
</source>
 
+
=== 세션의 PGA 사용량===
 +
<source lang=sql>
 +
set lines 2000
 +
SELECT SID, b.NAME, ROUND(a.VALUE/(1024*1024),2) MB FROM
 +
v$sesstat a, v$statname b
 +
WHERE (NAME LIKE '%session uga memory%' OR NAME LIKE '%session pga memory%')
 +
AND a.statistic# = b.statistic# order by ROUND(a.VALUE/(1024*1024),2) desc
 +
</source>
  
  
 
출처 : https://dbaclass.com/monitor-your-db/
 
출처 : https://dbaclass.com/monitor-your-db/

2024년 7월 11일 (목) 19:54 판

thumb_up 추천메뉴 바로가기


1 유저의 모든 세션 트레이스[편집]

--- CREATE THE BELOW TRIGGER TO ENABLE TRACE ALL SESSION OF USER ( SCOTT)
CREATE OR REPLACE TRIGGER USER_TRACE_TRG
AFTER LOGON ON DATABASE
BEGIN
    IF USER = 'SCOTT'
  THEN
    execute immediate 'alter session set events ''10046 trace name context forever, level 12''';
  END IF;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
/

2 커셔 내부 SQL의 상세내용 보기[편집]

select module,parsing_schema_name,inst_id,sql_id,plan_hash_value,child_number,sql_fulltext,
to_char(last_active_time,'DD/MM/YY HH24:MI:SS' ),sql_plan_baseline,executions,
elapsed_time/executions/1000/1000,rows_processed from gv$sql
where sql_id in ('&sql_id');

3 커셔 내부 sql쿼리 Flush[편집]

-- First get the address, hash_value of the sql_id

select ADDRESS, HASH_VALUE from V$SQLAREA where SQL_ID like '5qd8a442c328k';

ADDRESS          HASH_VALUE
---------------  ------------
C000007067F39FF0  4000666812

-- Now flush the query

SQL> exec DBMS_SHARED_POOL.PURGE ('C000007067F39FF0, 4000666812', 'C');

Note : For RAC, same need to be executed on all the nodes .

4 sql_id 의 바인드변수 값 조회[편집]

SELECT
sql_id,
b. LAST_CAPTURED,
t.sql_text sql_text,
b.HASH_VALUE,
b.name bind_name,
b.value_string bind_value
FROM
gv$sql t
JOIN
gv$sql_bind_capture b using (sql_id)
WHERE
b.value_string is not null
AND
sql_id='&sqlid'
/

5 현재 트랜잭션 조회[편집]

col name format a10
col username format a8
col osuser format a8
col start_time format a17
col status format a12
tti 'Active transactions'

select s.sid,username,t.start_time, r.name, t.used_ublk "USED BLKS",
decode(t.space, 'YES', 'SPACE TX',
decode(t.recursive, 'YES', 'RECURSIVE TX',
decode(t.noundo, 'YES', 'NO UNDO TX', t.status)
)) status
from sys.v_$transaction t, sys.v_$rollname r, sys.v_$session s
where t.xidusn = r.usn
and t.ses_addr = s.saddr
/

6 리스너 트레이스[편집]

- Set to the listener you want to trace

LSNRCTL> set cur LISTENER_TEST

-- Enable Trace:

LSNRCTL> set trc_level ADMIN
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_TEST)))
LISTENER_TEST parameter "trc_level" set to admin
The command completed successfully

7 세션의 PGA 사용량[편집]

set lines 2000
SELECT SID, b.NAME, ROUND(a.VALUE/(1024*1024),2) MB FROM
v$sesstat a, v$statname b
WHERE (NAME LIKE '%session uga memory%' OR NAME LIKE '%session pga memory%')
AND a.statistic# = b.statistic# order by ROUND(a.VALUE/(1024*1024),2) desc


출처 : https://dbaclass.com/monitor-your-db/