View Source
-- 1. 테이블 생성
DROP TABLE T;
CREATE TABLE T AS
SELECT *
FROM ALL_OBJECTS
;
-- 2. 테이블 UPDATE
UPDATE T
SET OBJECT_ID = ROWNUM
;
COMMIT;
-- 3. 인덱스 생성
CREATE UNIQUE INDEX T_U1 ON T(OBJECT_ID);
-- 4. 통계정보 생성
BEGIN
DBMS_STATS.GATHER_TABLE_STATS(USER,
'T',
CASCADE => TRUE);
END;
/
-- 5. 통계정보 확인
@STAT
COLUMN_NAME DATA_TYPE DATA_LEN Null DISTINCT_KEY DENSITY NUM_NULLS NUM_BUCKETS SAMPLE_SIZE LAST Analyzed
------------------------------ ---------- -------- ---- -------------- ---------- -------------- ----------- -------------- -------------------
CREATED DATE 7 N 28,849 .000034663 0 1 52,908 2009-12-01 21:39:13
DATA_OBJECT_ID NUMBER 22 Y 231,041 4.3282E-06 640,896 1 231,079 2009-12-01 21:39:13
GENERATED VARCHAR2 1 Y 2 .5 0 1 5,340 2009-12-01 21:39:13
LAST_DDL_TIME DATE 7 N 29,401 .000034012 0 1 52,908 2009-12-01 21:39:13
OBJECT_ID NUMBER 22 N 871,975 1.1468E-06 0 1 5,340 2009-12-01 21:39:13
OBJECT_NAME VARCHAR2 30 N 275,980 3.6235E-06 0 1 871,975 2009-12-01 21:39:13
OBJECT_TYPE VARCHAR2 19 Y 22 .045454545 0 1 5,340 2009-12-01 21:39:13
OWNER VARCHAR2 30 N 197 .005076142 0 1 5,340 2009-12-01 21:39:13
SECONDARY VARCHAR2 1 Y 2 .5 0 1 5,340 2009-12-01 21:39:13
STATUS VARCHAR2 7 Y 1 1 0 1 5,340 2009-12-01 21:39:13
SUBOBJECT_NAME VARCHAR2 30 Y 3,958 .000252653 776,936 1 5,874 2009-12-01 21:39:13
TEMPORARY VARCHAR2 1 Y 2 .5 0 1 5,340 2009-12-01 21:39:13
TIMESTAMP VARCHAR2 19 Y 30,744 .000032527 0 1 52,908 2009-12-01 21:39:13
NUMBER_ROWS CLUSTERING BLEVEL AvgLfBlperKEY INITRAN Init/Next/ FLst/
OWNER.INDEX_NAME TABLESPACE DISTINCT_KEY FACTOR LEAF_BLOKCS AvgDtBlperKEY DEG LOGGIN MAXTRAN MIN/MAX FGrp LAS
---------------------------------------- ---------------------- --------------- -------------- ------------ ------------- ---- ------ ------- ------------- ----- ---
USER.T_U1 USER_DATA 871,975 12,325 [2] 1 1 YES 2/255 128k/128k / 200
871,975 1,820 1 1/unlimit
OWNER.INDEX_NAME Uniq Type Status Drop COLUMN LIST
---------------------------------------- ---- ------ ------ ---- ----------------------------------------------------------------------------------------------------
USER.T_U1 UNIQ NORMAL VALID NO OBJECT_ID
-- 6. Trace 실행
@mysess
MY_SESSION_INFO
--------------------------------------------------
Sid, Serial# : 9964, 50
OS Process : 2452:4440 (CPID), 627066 (SPID)
ALTER SESSION SET EVENTS '10046 trace name context forever, level 4';
VAR VAL NUMBER
EXEC :VAL := 1000;
SELECT OBJECT_NAME
FROM T
WHERE OBJECT_ID = :VAL
;
OBJECT_NAME
-----------------
V_$ENQUEUE_STAT
ALTER SESSION SET SQL_TRACE=FALSE;
-- 7. TRC 파일 직접 확인
-- 바인드 변수를 실제 실행하는 시점이 CURSOR를 PARSING 하고 난 이후임을 알 수 있음
PARSING IN CURSOR #3 len=52 dep=0 uid=44 oct=3 lid=44 tim=9138570012406 hv=4215685038 ad='6148aef0'
SELECT OBJECT_NAME
FROM T
WHERE OBJECT_ID = :VAL
END OF STMT
PARSE #3:c=0,e=602,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=1,tim=9138570012400
BINDS #3:
kkscoacd
Bind#0
oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00
oacflg=03 fl2=1000000 frm=00 csi=00 siz=24 off=0
kxsbbbfp=11049ac98 bln=22 avl=02 flg=05
value=1000
EXEC #3:c=0,e=3008,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=1,tim=9138570015551
FETCH #3:c=0,e=139,p=0,cr=4,cu=0,mis=0,r=1,dep=0,og=1,tim=9138570015811
FETCH #3:c=0,e=1,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=0,tim=9138570017748
SELECT A.KSPPINM NAME,
B.KSPPSTVL VALUE,
B.KSPPSTDF DEF_YN,
A.KSPPDESC DESCRIPTION
FROM X$KSPPI A,
X$KSPPSV B
WHERE A.INDX = B.INDX
AND LOWER(A.KSPPINM) LIKE '%' || TRIM(LOWER('_optim_peek_user_binds')) || '%'
ORDER BY 1
;
NAME VALUE DEF_YN DESCRIPTION
---------------------- ----- ------ ------------------------------
_optim_peek_user_binds FALSE FALSE enable peeking of user binds
SELECT /*+ FULL(A) */
*
FROM 아파트매물 A
WHERE :CITY IN ('서울시', '경기도')
UNION ALL
SELECT /*+ INDEX(A IDX01) */
*
FROM 아파트매물 B
WHERE :CITY NOT IN ('서울시', '경기도')
AND 도시 = :CITY;
IF :CITY IN ('서울시', '경기도') THEN
SELECT /*+ FULL(A) */
*
FROM 아파트매물 A;
ELSE
SELECT /*+ INDEX(A IDX01) */
*
FROM 아파트매물 B
WHERE 도시 = :CITY;
END IF;
Powered by a free Atlassian Confluence Open Source Project License granted to phoca. Evaluate Confluence today.
Powered by Atlassian Confluence 2.10.4, the Enterprise Wiki. Bug/feature request - Atlassian news - Contact administrators