|
SQL TRACE FACILITY ´Â SQL ¹® »ç¿ë¿¡´ëÇÑ ¼º´ÉÀ» ºÐ¼®ÇϱâÀ§Çؼ »ç¿ëµÈ´Ù.
ÀÌ·¯ÇÑ SQL TRACE FACILITY ¸¦ ÀÌ¿ëÇÏ¸é °¢ SQL ¹®¿¡ ´ëÇؼ ´ÙÀ½°ú °°Àº
Á¤º¸¸¦ ¾òÀ»¼ö ÀÖ´Ù.
. parse,execute,fetch count
. CPU ¿Í elapsed ½Ã°£
. physical reads ¿Í logical reads
. ó¸®µÈ row ÀÇ ¼ö
SQL TRACE FACILITY ´Â SESSION ȤÀº INSTANCE ´ÜÀ§·Î ÇÒ ¼ö ÀÖ°í TRACE °á°ú
ÈÀÏÀº tkprof UTILITY ¿¡ÀÇÇØ »ç¿ëÀÚ°¡ ÀÐÀ»¼ö ÀÖ´Â ÇüÅ·Πº¯È¯½ÃŲ´Ù.
SQL TRACE SET UP ÇÏ¿© »ç¿ëÇϴ¹æ¹ý
----------------------------------
1. SQL TRACE enable ¹× TRACE ÈÀÏ µð·ºÅ丮 ÁöÁ¤
< INSTANCE ´ÜÀ§ >
?/dbs/initSID.ora ÈÀÏ¿¡ ´ÙÀ½ µÎ°³ÀÇ PARAMETER ¸¦ Ãß°¡ÇÏ°í DATABASE ¸¦ ´Ù½Ã STARTUP ½ÃŲ´Ù.
sql_trace = true
timed_statistics = true
timed_statistics Àº ½Ã½ºÅÛ¿¡ ¸¹Àº LOAD °¡ °É¸®¹Ç·Î »ç¿ëÇÏÁö ¾Ê´Â°ÍÀÌ
ÁÁ´Ù
< SESSION ´ÜÀ§ >
SQL*PLUS
$ sqlplus scott/tiger
SQL > ALTER SESSION SET SQL_TRACE = TRUE;
SQLFORMS30, RUNFORM30 : -s OPTION »ç¿ë
$ runform30 -s frmfile scott/tiger -c vt220
PRO*C
EXEC SQL CONNECT :username;
EXEC SQL ALTER SESSION SET SQL_TRACE = TRUE;
TRACE FILE µð·ºÅ丮´Â initSID.ora ÈÀÏ¿¡ ´ÙÀ½°ú°°ÀÌ ÁöÁ¤ÇÏ°í
ÁöÁ¤ÇÏÁö¾ÊÀ¸¸é ?/rdbms/log µð·ºÅ丮¿¡ »ý±ä´Ù.
user_dump_dest = /user/dump
2. SQL ¹® ½ÇÇà
TRACE ÈÀÏÀº SESSION ´ÜÀ§·Î 1 °³¾¿ »ý±èÀ¸·Î ÇÑ SESSION ¿¡¼ »ç¿ëµÈ ¸ðµç
SQL ¹®ÀÇ TRACE °á°ú´Â 1°³ÀÇ ÈÀÏ¿¡ Á¸ÀçÇϰԵȴÙ.
¿¹. SQL> ALTER SESSION SET SQL_TRACE = TRUE;
SQL> SELECT COUNT(*) FROM EMP E,DEPT D
WHERE E.DEPTNO = D.DEPTNO;
SQL> EXIT;
3. TRACE ÈÀÏ º¯È¯
2. ´Ü°è¿¡¼ SQL ¹®À» ½ÇÇàÇϸé user_dump_dest ¿¡ ÁöÁ¤µÈ µð·ºÅ丮¿¡
TRACE ÈÀÏÀÌ »ý±â°í tkprof ¸¦ÀÌ¿ëÇÏ¿© ÈÀÏÀ» º¯È¯½ÃŲ´Ù. TRACE ÈÀÏÀº ½±°Ô
ãÀ» ¼ö ÀÖ´Â ÇüÅ°¡ ¾Æ´Ï¹Ç·Î SQL¹®À» ½ÇÇàÇϱâ Àü¿¡ dump µð·ºÅ丮¿¡ ÀÖ´Â
ora_xxxx.trcÈÀÏÀ» ¸ðµÎ »èÁ¦Çϰųª °¡ÀåÃÖ±Ù¿¡ »ý±ä ÈÀÏÁß¿¡¼ ã¾Æ¾ß ÇÑ´Ù.
¿¹. $ cd $ORACLE_HOME/rdbms/log
$ tkprof ora_1111 out sort=fchqry,fchcu explain=scott/tiger print=20
ora_1111 : TRACE ÈÀÏ
out : OUTPUT ÈÀÏ. µð·ºÅ丮¿¡ out.prf ·Î »ý±ä´Ù.
sort : ÁöÁ¤µÈ OPION(fchqry,fchcu) ¿¡ ASCENDING ¼øÀ¸·Î SQL ¹®À»
SORTING ÇÑ´Ù.
explain : SQL ¹®ÀÇ EXECUTION PLAN À» ¹ß»ý½ÃŲ´Ù.
print : ÁöÁ¤µÈ °¹¼öÀÇ SQL¹®¿¡´ëÇؼ¸¸ TRACE °á°ú¸¦ PRINT ÇÑ´Ù.
4. SQL TRACE °á°ú ºÐ¼®
**********************************************************************
count = number of times OCI procedure was executed
cpu = cpu time in seconds executing
elapsed = elapsed time in seconds executing
disk = number of physical reads of buffers from disk
query = number of buffers gotten for consistent read
current = number of buffers gotten in current mode (usually forupdate)
rows = number of rows processed by the fetch or execute call
**********************************************************************
SELECT COUNT(*)
FROM EMP E,DEPT D WHERE E.DEPTNO=D.DEPTNO
call count cpu elapsed disk query current rows
-----------------------------------------------------------------
Parse 2 0.00 0.00 0 0 0 0
Execute 2 0.00 0.00 0 0 0 0
Fetch 2 0.00 0.00 0 33 2 1
Misses in library cache during parse: 1
Parsing user id: 8 (SCOTT)
Rows Execution Plan
------- ---------------------------------------------------
0 SELECT STATEMENT
0 SORT (AGGREGATE)
16 NESTED LOOPS
16 TABLE ACCESS (FULL) OF 'EMP'
16 INDEX (UNIQUE SCAN) OF 'DEPT_PRIMARY_KEY' (UNIQUE)
*********************************************************************
ºÐ¼®¿¹)
a. cpu, elapsed Á¤º¸°¡¾ø´Â °æ¿ì´Â initSID.ora ¿¡
timed_stattistic = false ·Î µÇ¾î Àֱ⶧¹®ÀÌ´Ù.
b. Execute count ¿Í Fectch count °¡ µ¿ÀÏÇÏ°Ô Å©´Ù°íÇϸé ARRAY FETCH
»ç¿ëÀ» °í·ÁÇÔ.
c. fetch µÈ rows ¼ö : query + current = 1 : 4 ÀÌÇÏÀ̸é SQL ¹®Àº
ÀûÀýÈ÷ »ç¿ëµÈ °æ¿ìÀÌ°í, row ¼ö¿¡ºñÇÏ¿© query + count °¡ »ó´çÈ÷
Å©¸é ºÎÀû ÇÏ°Ô »ç¿ëµÈ SQL ¹®À̹ǷÎ( count,sum,distinct µî Group
function À» »ç¿ëÇϴ°æ¿ì´Â ¿¹¿Ü) ´ÙÀ½ ³»¿ëµé¿¡´ëÇؼ Àç °ËÅä°¡
ÇÊ¿äÇÏ´Ù.
.INDEX »ç¿ë,±¸¼º¿©ºÎ
.ROWID »ç¿ë
.COST_BASED OPTIMIZER »ç¿ë(ORACLE7)
.ARRAY FETCH »ç¿ë
.SORTING À» ÇÇÇÒ¼ö ÀÖ´Â SQL ¹® ±¸»ç
d. Parse count,Execute count °¡ ºñ½ÁÇÑ°æ¿ì RELEASE_CURSOR,
HOLE_CURSOR OPTION »ç¿ëÇÏ¿© Parse count ¸¦ ÁÙÀÓ.
|