03B
About 1 min
03B κ΄λ ¨
trace
1. ν μ€νΈ ν μ΄λΈ μμ±
CREATE TABLE big_table AS
SELECT
*
FROM dba_tables, (SELECT level FROM DUAL CONNECT BY level <= 1000)
WHERE 1=1;
2. μ€μ΅ sql
SELECT * FROM big_table WHERE 1=1
AND owner = 'SYSTEM'
AND tablespace_name = 'SYSTEM'
AND table_name LIKE 'REPCAT$%'
ORDER BY table_name DESC;
3. μ€μ μ€νκ³ν λ° statistics νμΈ
3.1 trace file λ‘ νμΈ
-- 3.1.1. trace file ꡬλΆμ μν identifier μ μ©
ALTER session SET tracefile_identifier = 'hnj';
--
--
-- 3.1.2. `trace` μμ±νμΌ νμΈ
SELECT
r.value || '/' || LOWER(t.instance_name) ||
'_ora_' || LTRIM(TO_CHAR(p.spid)) || '_hnj' ||
'.trc' trace_file
FROM
v$process p
, v$session s
, v$parameter r
, v$instance t
WHERE 1=1
AND p.addr = s.paddr
AND r.name = 'user_dump_dest'
AND s.sid = (SELECT sid FROM v$mystat WHERE 1=1 AND rownum = 1)
;
---
---
--- 3.1.3. μΈμ
μ trace μ μ©
ALTER session SET EVENTS '10046 trace name context forever, level 12' ; -- level 12λ‘ μμ±
---
---
--- 3.1.4. μ€μ΅ sql μν
SELECT *
FROM BIG_TABLE
WHERE OWNER = 'SYSTEM'
AND TABLESPACE_NAME = 'SYSTEM'
AND TABLE_NAME LIKE 'REPCAT$%'
ORDER BY TABLE_NAME DESC;
---
--- 3.1.5. μΈμ
μ trace off
ALTER SESSION SET EVENTS '10046 trace name context forever, off';
- 3.1.2 μμ νμΈν νμΌ κ²½λ‘ λ° νμΌλͺ
μμΉλ‘ μ΄λ ν
tkprof
λ‘trace
νμΌ μμ±
tkprof ~.trc chg_trc.txt sys=no
μ°Έμ‘°: http://blog.hkwon.me/oracle-sql-trace-tkprof/
chg_trc.txt
νμΌνμΈ
trace νμΌ νμΈνμ¬ sql μνμκ° μ½μ λΈλ μ€νκ²ν λ± νμΈ
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 0.01 0.00 0 86 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 3 0.01 0.00 0 86 0 1
3.2 dbms_xplan
νμΈ
-- 3.2.1 μΈμ
μ statistics_level μ€μ
ALTER session SET statistics_level = 'ALL';
--
--
-- 3.2.2 μ€μ΅sql μν
SELECT * FROM big_table WHERE 1=1
AND owner = 'SYSTEM'
AND tablespace_name = 'SYSTEM'
AND table_name LIKE 'REPCAT$%'
ORDER BY table_name DESC;
--
--
-- 3.2.3 dbms_xplan.display_cursor νμΈ
SELECT * FROM TABLE(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));
--
--