[답변] 실행계획을 봤습니다만... 한번 더 부탁드립니다. ^^; 0 4 3,007

by 윤태영 [2007.08.24 14:16:52]


안녕하세요? 다시 한번 더 부탁드립니다. ^^

최종 조회 문장과 실행계획 입니다만,

정확히 어디가 문제인지는;;; 잘 모르겠습니다.

 

 

※ 그리고, 이게 잘 나온거라면, EXTRACTVALUE 부분을 튜닝해야하는 건가요?

 

 

1. 최종 조회 문장

SELECT EXTRACTVALUE(A.XBRLDOC,
                    '/xbrl/rapm:StdDev_4W',
                    'xmlns="http://www.xbrl.org/2003/instance" xmlns:rapm="http://www.company.com/rapm/2007-10-01"') "STD_DEV",
       EXTRACTVALUE(B.XBRLDOC,
                    '/xbrl/crapm:AvgRt_4W',
                    'xmlns="http://www.xbrl.org/2003/instance" xmlns:crapm="http://www.company.com/crapm/2007-10-01"') "AVGRT"
FROM   TBL_RAPM  A,
       TBL_CRAPM B
WHERE  A.TRD_DT   = '20070616'
AND    B.PEER_CD  = 'A1111'
AND    B.TRD_DT   = A.TRD_DT
AND    (A.PROD_CD, B.CO_CD) IN (SELECT PROD_CD , CO_CD
                                FROM   (SELECT PROD_CD
                                             , EXTRACTVALUE(XBRLDOC,
                                                            '/xbrl/info:CoCd',
                                                            'xmlns="http://www.xbrl.org/2003/instance" xmlns:info="http://www.company.com/info/2007-10-01"') CO_CD
                                             , ROW_NUMBER() OVER(PARTITION BY PROD_CD ORDER BY CHG_DT DESC) CNT
                                        FROM   TBL_INFO D
                                        WHERE SUBSTR(EXTRACTVALUE(XBRLDOC,
                                                                  '/xbrl/info:CloseGb',
                                                                  'xmlns="http://www.xbrl.org/2003/instance" xmlns:info="http://www.company.com/info/2007-10-01"'), 1, 1) = '1'
                                           AND SUBSTR(EXTRACTVALUE(XBRLDOC,
                                                                   '/xbrl/info:PeerCd',
                                                                   'xmlns="http://www.xbrl.org/2003/instance" xmlns:info="http://www.company.com/info/2007-10-01"'), 1, 8) = 'A1111'
                                        )
                                WHERE  CNT = 1)
;


2. 실행계획

--------------------------------------------------------------------------------------------------------
| Operation                           |  Name                  |  Rows | Bytes|  Cost  | Pstart| Pstop |
--------------------------------------------------------------------------------------------------------
| SELECT STATEMENT                    |                        |     3 |    6K|     16 |       |       |
|  NESTED LOOPS                       |                        |     3 |    6K|     16 |       |       |
|   HASH JOIN                         |                        |     2 |    4K|     14 |       |       |
|    TABLE ACCESS BY INDEX ROWID      |TBL_CRAPM               |    16 |    1K|      4 |       |       |
|     INDEX RANGE SCAN                |PK_TBL_CRAPM            |    16 |      |      2 |       |       |
|    VIEW                             |VW_NSO_1                |     7 |   13K|      9 |       |       |
|     SORT UNIQUE                     |                        |     7 |   13K|        |       |       |
|      VIEW                           |                        |     7 |   13K|      9 |       |       |
|       WINDOW SORT PUSHED RANK       |                        |     7 |  462 |      9 |       |       |
|        TABLE ACCESS BY INDEX ROWID  |TBL_INFO                |     7 |  462 |      2 |       |       |
|         INDEX RANGE SCAN            |TBL_INFO_FX4            |     1 |      |      1 |       |       |
|   TABLE ACCESS BY INDEX ROWID       |TBL_RAPM                |     1 |   97 |      1 |       |       |
|    INDEX UNIQUE SCAN                |PK_TBL_RAPM             |     1 |      |        |       |       |
--------------------------------------------------------------------------------------------------------

 

Plan

SELECT STATEMENT  CHOOSE
Cost : 16 Bytes : 6,561 Cardinality : 3        

 12 NESTED LOOPS  Cost : 16 Bytes : 6,561 Cardinality : 3       
  9 HASH JOIN  "B"."CO_CD"="VW_NSO_1"."$nso_col_2"Cost : 14 Bytes : 4,180 Cardinality : 2      
   2 TABLE ACCESS BY INDEX ROWID UDBA.TBL_CRAPM Cost : 4 Bytes : 1,280 Cardinality : 16     
    1 INDEX RANGE SCAN UDBA.PK_TBL_CRAPM "B"."PEER_CD"='A1111' AND "B"."TRD_DT"='20070616'Cost : 2 Cardinality : 16    
   8 VIEW SYS.VW_NSO_1 Cost : 9 Bytes : 14,070 Cardinality : 7     
    7 SORT UNIQUE  Bytes : 14,161 Cardinality : 7    
     6 VIEW UDBA. "from$_subquery$_003"."CNT"=1Cost : 9 Bytes : 14,161 Cardinality : 7   
      5 WINDOW SORT PUSHED RANK  ROW_NUMBER() OVER ( PARTITION BY "D"."PROD_CD" ORDER BY "D"."CHG_DT" DESC )<=1Cost : 9 Bytes : 462 Cardinality : 7  
       4 TABLE ACCESS BY INDEX ROWID UDBA.TBL_INFO Cost : 2 Bytes : 462 Cardinality : 7 
        3 INDEX RANGE SCAN UDBA.TBL_INFO_FX4 SUBSTR(EXTRACTVALUE(SYS_MAKEXML("D"."SYS_NC00004$"),'/xbrl/info:CloseGb','xmlns="http://www.xbrl.org/2003/instance" xmlns:info="http://www.company.com/info/2007-10-01"'),1,1)='1' AND SUBSTR(EXTRACTVALUE(SYS_MAKEXML("D"."SYS_NC00004$"),'/xbrl/info:PeerCd','xmlns="http://www.xbrl.org/2003/instance" xmlns:info="http://www.company.com/info/2007-10-01"'),1,8)='A1111'Cost : 1 Cardinality : 1
  11 TABLE ACCESS BY INDEX ROWID UDBA.TBL_RAPM Cost : 1 Bytes : 97 Cardinality : 1      
   10 INDEX UNIQUE SCAN UDBA.PK_TBL_RAPM "A"."PROD_CD"="VW_NSO_1"."$nso_col_1" AND "A"."TRD_DT"='20070616'Cardinality : 1     

 


 


 

by 강정식 [2007.08.24 00:00:00]
조건상으로 봐서는
TBL_RAPM 테이블이 TBL_CRAPM 테이블보다 먼저
풀려야 할 것 같은데 나중에 풀리네요
힌트를 한번 줘보세요

FROM절은 A -> B로 되어있으니 힌트는
/*+ ORDERED */ 를 주시면 될 것 같습니다.

이렇게 되겠죠.

SELECT /*+ ORDERED */
EXTRACTVALUE(A.XBRLDOC,
'/xbrl/rapm:StdDev_4W',
'xmlns="http://www.xbrl.org/2003/instance" xmlns:rapm="http://www.company.com/rapm/2007-10-01"') "STD_DEV",
EXTRACTVALUE(B.XBRLDOC,
'/xbrl/crapm:AvgRt_4W',
'xmlns="http://www.xbrl.org/2003/instance" xmlns:crapm="http://www.company.com/crapm/2007-10-01"') "AVGRT"

by 윤태영 [2007.08.24 00:00:00]
힌트를 줘보고 실행을 해봤습니다만,
ORDERED 를 주는 것과 차이가 없습니다. ^^;
훌륭한 답변 항상 감사드립니다.

며칠째 계속 이 문장과 싸우고 있는데요. 큰 변화가 없네요. ㅎㅎ;;

by 강정식 [2007.08.24 00:00:00]
Trace를 뜨실 줄 아시다면 떠서 한번 올려주세요
Trace의 결과를 봐야 정확히 판단할 수 있을 것 같습니다.
그리고 펑션 안의 쿼리도 함께 올려주세요

by 윤태영 [2007.08.24 00:00:00]
XBRLDOC 은 XMLTYPE 컬럼이구요.
EXTRACTVALUE() 는 XMLTYPE API인데요.
XPATH를 이용해서 그냥 값만 뽑아오는 함수입니다.

sqlplus나 토드 이용해서 작업만 하기에...
Trace는 잘 몰라서;;; 찾아봤습니다만 제가 가진권한으로 수행을 할수 없을 듯 합니다.
혹시 제PC에서 추출할 수 있는 방법이 있는지요?
댓글등록
SQL문을 포맷에 맞게(깔끔하게) 등록하려면 code() 버튼을 클릭하여 작성 하시면 됩니다.
로그인 사용자만 댓글을 작성 할 수 있습니다. 로그인, 회원가입