안녕하세요.
같은 테이블을 내부 쿼리에 사용하는데 조회 시간이 오래 걸려서
혹시 다른 방법이 없을까 하고 질문 올립니다.
SELECT a.code, a.description,
(SELECT count(b.code)
FROM TEST b
WHERE b.rec_date >to_char(add_months('20150727',-6),'yyyymmdd')
AND b.description = a.description
) date1
FROM TEST a
WHERE a.reg_date = '20150727'
리스트는 a.reg_date가 20150727인 code와 description와 최근 6개월간 description이 같은 데이터 개수
이렇게 알고 싶은데...
시간이 꽤 걸리다 보니..
혹시 다른 방법이 있는지 궁금합니다..
아래 형식으로 뽑아서 드리면 되는건가요??확인부탁드릴게요 ! ㅜ
<ExplainPlan>
<PlanElement id="0" operation="SELECT STATEMENT" optimizer="ALL_ROWS" cost="3,302" cardinality="263" bytes="4,734" cpu_cost="163,784,412" io_cost="3,292" time="40">
<PlanElements>
<PlanElement id="1" operation="SORT" option="AGGREGATE" cardinality="1" bytes="13">
<PlanElements>
<PlanElement object_ID="0" id="2" operation="TABLE ACCESS" option="FULL" optimizer="ANALYZED" object_owner="AAAAA" object_name="T2WORK_ORDER" object_type="TABLE" object_instance="1" cost="3,307" cardinality="65" bytes="845" cpu_cost="233,356,795" io_cost="3,292" filter_predicates=""EQ_POSITION"=:B1 AND "REC_DATE">=TO_CHAR(ADD_MONTHS('20150721',(-6)),'yyyymmdd')" time="40"/>
</PlanElements>
</PlanElement>
<PlanElement object_ID="0" id="3" operation="TABLE ACCESS" option="FULL" optimizer="ANALYZED" object_owner="AAAAA" object_name="T2WORK_ORDER" object_type="TABLE" object_instance="2" cost="3,302" cardinality="263" bytes="4,734" cpu_cost="163,784,412" io_cost="3,292" filter_predicates=""X"."REC_DATE"='20150721'" time="40"/>
</PlanElements>
</PlanElement>
</ExplainPlan>
이렇게 올려주시면 확인이 불가합니다....
현재 토드가 없으니, sqlplus로 설명드릴게요.
1. 접속 : sqlplus ID/PASSWORD@SID
2. 플랜뜨기 : set autot traceonly exp
3. 플랜확인
ex )
C:\Users\LDCC>sqlplus test/test@event
SQL*Plus: Release 11.2.0.4.0 Production on 월 7월 27 17:22:27 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
다음에 접속됨:
Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production
With the Partitioning option
JServer Release 9.2.0.7.0 - Production
SQL> set autot traceonly exp
SQL> select * from dual;
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE
1 0 TABLE ACCESS (FULL) OF 'DUAL'
SQL>