Browse Source

쿼리 속도 개선

DESKTOP-P60829B\User 1 year ago
parent
commit
457e957c38
1 changed files with 52 additions and 36 deletions
  1. 52 36
      src/main/resources/sqlmap/mappers/co/co0108/CO01080001UMapper.xml

+ 52 - 36
src/main/resources/sqlmap/mappers/co/co0108/CO01080001UMapper.xml

@@ -66,41 +66,57 @@
 	</select>
 	</select>
 	
 	
 	<select id="getList3" resultType="easyHashMap">
 	<select id="getList3" resultType="easyHashMap">
-        SELECT A.CMPN_CD 
-             , A.STD_YM 
-             , A.CCGRP_CD
-             , A.CCGRP_NM 
-             , A.CC_CD
-             , A.CC_NM
-             , A.EMP_PM_NM --PM
-             , A.EMP_PE_NM --PE
-             , A.EMP_PS_NM --공무
-             , NVL(C.RT_PROG_PLAN_O,0) RT_PROG_PLAN_O -- Plan 
-             , NVL(C.RT_PROG_ACT_O,0) RT_PROG_ACT_O--Actual
-          FROM CON_PJT_MST A
-          LEFT JOIN SM_COM_CMPN B ON A.CMPN_CD  = B.CMPN_CD 
-          LEFT JOIN WC_Z_ETEC_PJT_PROGRESS@ERPSQL C ON C.CD_COMPANY = B.MAP_CMPN_CD AND C.CD_SITE = A.CC_CD AND SUBSTR(C.YM_PROG,0,6) = A.STD_YM
-          LEFT JOIN CON_PJT_RESN D ON A.CMPN_CD = D.CMPN_CD AND A.STD_YM = D.STD_YM AND A.CC_CD = D.CC_CD
-		  JOIN 	(
-		  			SELECT DISTINCT B.CMPN_CD, A.CD_SITE 
-					  FROM WC_S_SITEAUTH@ERPSQL A 
-					  JOIN SM_COM_CMPN B ON B.MAP_CMPN_CD = A.CD_COMPANY
-					 WHERE B.CMPN_CD = #{cmpnCd}
-					   AND A.ID_USER LIKE CASE WHEN #{empNo} IN (SELECT SPEC_CD FROM SM_COM_COMMCD_D A, SM_COM_COMMCD B WHERE A.COMM_CD_ID = B.COMM_CD_ID AND B.COMM_CD = 'CO003' AND A.USE_YN = 'Y') THEN '%' ELSE #{empNo} END
-		  		) Z ON Z.CMPN_CD = A.CMPN_CD AND Z.CD_SITE = A.CC_CD 
-         WHERE A.CMPN_CD = #{cmpnCd}
-           AND A.STD_YM = #{stdYm}
-        <if test="ccgrpCd != 'all'">
-           AND A.CCGRP_CD = #{ccgrpCd}
-        </if>
-           AND A.CC_CD NOT IN (SELECT SPEC_CD FROM SM_COM_COMMCD_D A, SM_COM_COMMCD B WHERE A.COMM_CD_ID = B.COMM_CD_ID AND B.COMM_CD = 'CO004' AND A.USE_YN = 'Y')
-           AND D.COMPL_CD = '01'
-        <if test="gubun == '02'">
-           AND ( NVL(C.RT_PROG_PLAN_O,0) > 0 OR NVL(C.RT_PROG_ACT_O,0) > 0 )
-        </if>
-        <if test="gubun == '03'">
-           AND ( NVL(C.RT_PROG_PLAN_O,0) = 0 AND NVL(C.RT_PROG_ACT_O,0) = 0 )
-        </if>
-         ORDER BY A.CMPN_CD, A.STD_YM, A.CCGRP_CD, A.CC_CD 
+	    SELECT CMPN_CD 
+             , STD_YM 
+             , CCGRP_CD
+             , CCGRP_NM 
+             , CC_CD
+             , CC_NM
+             , EMP_PM_NM --PM
+             , EMP_PE_NM --PE
+             , EMP_PS_NM --공무
+             , RT_PROG_PLAN_O -- Plan 
+             , RT_PROG_ACT_O--Actual
+	    FROM (
+		        SELECT A.CMPN_CD 
+		             , A.STD_YM 
+		             , A.CCGRP_CD
+		             , A.CCGRP_NM 
+		             , A.CC_CD
+		             , A.CC_NM
+		             , A.EMP_PM_NM --PM
+		             , A.EMP_PE_NM --PE
+		             , A.EMP_PS_NM --공무
+		             , NVL(C.RT_PROG_PLAN_O,0) RT_PROG_PLAN_O -- Plan 
+		             , NVL(C.RT_PROG_ACT_O,0) RT_PROG_ACT_O--Actual
+		          FROM CON_PJT_MST A
+		          LEFT JOIN SM_COM_CMPN B ON A.CMPN_CD  = B.CMPN_CD 
+		          LEFT JOIN WC_Z_ETEC_PJT_PROGRESS@ERPSQL C ON C.CD_COMPANY = B.MAP_CMPN_CD AND C.CD_SITE = A.CC_CD AND SUBSTR(C.YM_PROG,0,6) = A.STD_YM
+		          LEFT JOIN CON_PJT_RESN D ON A.CMPN_CD = D.CMPN_CD AND A.STD_YM = D.STD_YM AND A.CC_CD = D.CC_CD
+				  JOIN 	(
+				  			SELECT DISTINCT B.CMPN_CD, A.CD_SITE 
+							  FROM WC_S_SITEAUTH@ERPSQL A 
+							  JOIN SM_COM_CMPN B ON B.MAP_CMPN_CD = A.CD_COMPANY
+							 WHERE B.CMPN_CD = #{cmpnCd}
+							   AND A.ID_USER LIKE CASE WHEN #{empNo} IN (SELECT SPEC_CD FROM SM_COM_COMMCD_D A, SM_COM_COMMCD B WHERE A.COMM_CD_ID = B.COMM_CD_ID AND B.COMM_CD = 'CO003' AND A.USE_YN = 'Y') THEN '%' ELSE #{empNo} END
+				  		) Z ON Z.CMPN_CD = A.CMPN_CD AND Z.CD_SITE = A.CC_CD 
+		         WHERE A.CMPN_CD = #{cmpnCd}
+		           AND A.STD_YM = #{stdYm}
+		        <if test="ccgrpCd != 'all'">
+		           AND A.CCGRP_CD = #{ccgrpCd}
+		        </if>
+		           AND A.CC_CD NOT IN (SELECT SPEC_CD FROM SM_COM_COMMCD_D A, SM_COM_COMMCD B WHERE A.COMM_CD_ID = B.COMM_CD_ID AND B.COMM_CD = 'CO004' AND A.USE_YN = 'Y')
+		           AND D.COMPL_CD = '01'
+		         ORDER BY A.CMPN_CD, A.STD_YM, A.CCGRP_CD, A.CC_CD
+		     )
+		WHERE 1=1
+		    <if test="gubun == '02'">
+	           AND (RT_PROG_PLAN_O > 0 OR RT_PROG_ACT_O > 0 )
+	        </if>
+	        <if test="gubun == '03'">
+	           AND ( RT_PROG_PLAN_O = 0 AND RT_PROG_ACT_O = 0 )
+	        </if>
+	               
+		          
     </select>	
     </select>	
 </mapper>
 </mapper>