|
[SQL Trace]
½ÇÇàµÇ´Â SQL¹®Àå¿¡ ´ëÇØ ºÐ¼®Á¤º¸¸¦ Á¦°øÇϹǷΠ»ç¿ëÀÚ(ÇÁ·Î±×·¡¸Ó,..)°¡
ƯÁ¤ SQL¹®ÀåÀ» ¾î¶»°Ô »ç¿ëÇؾ߰ڴٴ °¡À̵å¶óÀÎÀ» Á¦°øÇØÁØ´Ù. EXPLAIN PLAN°ú
º´ÇàÇÏ¿© »ç¿ëÇÏ´Â °ÍÀÌ ÁÁ´Ù.
´ÙÀ½°ú °°Àº ºÐ¼®Á¤º¸¸¦ Á¦°øÇÑ´Ù.
1. parse,execute,fetch¼ö
2. CPU½Ã°£/°æ°úµÈ ½Ã°£
3. ¹°¸®Àû/³í¸®Àû reads
4. ó¸®µÈ ·Î¿ì¼ö
5. ¶óÀ̺귯¸® ij½¬ misses
6. ÆĽÌÀÌ ¹ß»ýÇÒ ¶§ÀÇ »ç¿ëÀÚ
7. Ä¿¹Ô/·Ñ¹é
SQL_TRACE¿Í °ü·ÃµÈ Æз¯¹ÌÅÍ´Â 3°¡Áö°¡ ÀÖ°í,
¸ðµÎ µ¿ÀûÆз¯¹ÌÅÍ(dynamic parameter)ÀÌ´Ù.
----------------------------------------------------------------------
-----------
1. timed_statistics
- CPU½Ã°£, ½ÇÇà½Ã°£µî ½Ã°£¿¡ °ü·ÃµÈ Á¤º¸¸¦ Ç¥½ÃÇϱâ À§ÇØ »ç¿ëµÈ´Ù.
- Áö¼ÓÀûÀÎ ¼³Á¤À» À§ÇØ Æз¯¹ÌÅÍÆÄÀÏ(init.ora)¿¡ ¼³Á¤Çϰųª
- ¼¼¼Ç¿¡¼¸¸ Àӽ÷Π¼³Á¤Çϱâ À§ÇØ
alter session set timed_statistics=true ·Î »ç¿ëÇÒ ¼ö ÀÖ´Ù.
2. max_dump_file_size
- Æ®·¹À̽ºÆÄÀÏÀÇ ÃÖ´ë Å©±â(´ÜÀ§: OSºí·°¼ö), ¹®¼¿¡´Â 500ÀÌ µðÆúÆ®¶ó°í ÇßÁö¸¸
½ÇÁ¦·Î´Â unlimited¿´´Ù.
- Áö¼ÓÀûÀÎ ¼³Á¤À» À§ÇØ Æз¯¹ÌÅÍÆÄÀÏ(init.ora)¿¡ ¼³Á¤Çϰųª
- ¼¼¼Ç¿¡¼¸¸ Àӽ÷Π¼³Á¤Çϱâ À§ÇØ alter session set max_dump_file_size=500 ·Î
»ç¿ëÇÒ ¼ö ÀÖ´Ù.
3. user_dump_dest
- Æ®·¹À̽ºÆÄÀÏÀÌ »ý¼ºµÉ µð·ºÅ丮
- ¿©±â¼´Â /u01/app/oracle/admin/dev/udump¶ó°í °¡Á¤ÇÑ´Ù.
- Áö¼ÓÀûÀÎ ¼³Á¤À» À§ÇØ Æз¯¹ÌÅÍÆÄÀÏ(init.ora)¿¡ ¼³Á¤Çϰųª
ÀνºÅϽº¿¡¼¸¸ Àӽ÷Π¼³Á¤Çϱâ À§ÇØ
alter system set user_dump_dest=/tmp ·Î »ç¿ëÇÒ ¼ö ÀÖ´Ù.
----------------------------------------------------------------------
-----------
SQL Trace´Â ¼¼¼Ç·¹º§ ȤÀº ÀνºÅϽº·¹º§¿¡¼ enableµÉ ¼ö ÀÖ´Ù.
ÀνºÅϽº·¹º§¿¡¼ ¸ðµç SQLÀ» Æ®·¹À̽ºÇÏ´Â °æ¿ì´Â °ÅÀÇ ¾øÀ¸¹Ç·Î
DBÀÀ¿ëÇÁ·Î±×·¥¿¡¼ »ç¿ëµÇ´Â ƯÁ¤ SQL¿¡ ´ëÇؼ¸¸ Æ®·¹À̽ºÇÏ´Â °ÍÀÌ ÀϹÝÀûÀÌ´Ù.
±×¸®°í Æ®·¹À̽º¸¦ enableÇϴ°ÍÀº ´ç¿¬È÷ DBÀÇ ºÎÇϸ¦ ¹ß»ýÇÏ´Â °ÍÀ̶ó ÇÊ¿äÇÒ¶§¸¸
»ç¿ëÇÏ°í Æò»ó½ÃÀÇ productionȯ°æ¿¡¼´Â disableÇÏ´Â °ÍÀÌ ÁÁ´Ù.
----------------------------------------------------------------------
-----------
enable : alter session set sql_trace=true ȤÀº
exec dbms_session.set_sql_trace(true)
disable: alter session set sql_trace=false ȤÀº
exec dbms_session.set_sql_trace(false)
----------------------------------------------------------------------
-----------
[SQL Trace »ç¿ë¿¹Á¦}
alter session set sql_trace=true
alter system set user_dump_dest=/tmp
[TKPROF]
¿À¶óŬ À¯Æ¿¸®Æ¼ ÇÁ·Î±×·¥À¸·Î OS»ó¿¡ ½ÇÇàÆÄÀÏ·Î Á¸ÀçÇÑ´Ù.
TKPROFÀº SQL Trace°¡ »ý¼ºÇÑ Æ®·¹À̽ºÆÄÀÏÀ» ºÐ¼®ÇÏ¿©
¿ì¸®°¡ ¾Ë¾Æº¸±â ½¬¿î Ãâ·ÂÆÄÀÏÀ» »ý¼ºÇÑ´Ù.
SQL¹®ÀåÀÌ ½ÇÇàµÉ¶§¸¶´Ù »ç¿ëµÈ ¸®¼Ò½º·®, ·Î¿ì¼ö µî¿¡ ´ëÇØ º¸°íÇÑ´Ù.
----------------------------------------------------------------------
-----------
(Ãâ·Â ¿¹)
select * from t t1 where object_id=55
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.02 0.01 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 0.00 0.00 0 4 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 3 0.02 0.01 0 4 0 0
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 49
Rows Row Source Operation
------- ---------------------------------------------------
0 TABLE ACCESS BY INDEX ROWID T
0 INDEX SKIP SCAN (object id 31310)
----------------------------------------------------------------------
-----------
[TKPROF »ç¿ë¿¹Á¦]
À§¿¡¼ ÁúÀÇÇß´ø °ÍµéÀº ora_17994.trc¶ó´Â Æ®·¹À̽ºÆÄÀÏ¿¡ ±â·ÏµÇ¾î ÀÖ´Ù.
Æ®·¹À̽ºÆÄÀϸíÀº ¾Õ¼ ¸»ÇßµíÀÌ ÆľÇÇϱâ Èûµå¹Ç·Î Àß Ã£¾Æ¾ß ÇÑ´Ù.
[oracle@dev2 udump]$ tkprof ora_17994.trc skip_scan_query_report.txt
[oracle@dev2 udump]$ cat skip_scan_query_report.txt
TKPROF: Release 9.0.1.0.0 - Production on Fri Mar 8 20:39:22 2002
(c) Copyright 2001 Oracle Corporation. All rights reserved.
Trace file: ora_17994.trc
Sort options: default
**************************************************************
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 for update)
rows = number of rows processed by the fetch or execute call
**************************************************************
select *
from
t t1 where object_id=55
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.02 0.01 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 0.00 0.00 0 4 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 3 0.02 0.01 0 4 0 0
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 49
Rows Row Source Operation
------- ---------------------------------------------------
0 TABLE ACCESS BY INDEX ROWID T
0 INDEX SKIP SCAN (object id 31310)
OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 4 0.03 0.02 0 0 0 0
Execute 6 0.00 0.00 0 0 0 0
Fetch 2 0.07 0.06 0 393 18 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 12 0.10 0.09 0 393 18 0
Misses in library cache during parse: 2
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 2 0.00 0.00 0 0 0 0
Execute 24 0.00 0.00 0 0 0 0
Fetch 24 0.00 0.00 0 48 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 50 0.00 0.00 0 48 0 0
Misses in library cache during parse: 0
6 user SQL statements in session.
2 internal SQL statements in session.
8 SQL statements in session.
**************************************************************
Trace file: ora_17994.trc
Trace file compatibility: 9.00.01
Sort options: default
1 session in tracefile.
6 user SQL statements in trace file.
2 internal SQL statements in trace file.
8 SQL statements in trace file.
5 unique SQL statements in trace file.
118 lines in trace file.
|