epmanxp
7/3/2018 - 1:12 AM

DB2 Join View

DB2 Join View 很慢時的解決方式

WITH ATABLE AS (
 SELECT AA,BB,CC FROM ATABLE
), 
BTABLE AS (
 SELECT * 
 FROM VIEW
 WHERE (KEY1,KEY2,KEY3) IN (SELECT AA,BB,CC FROM ATABLE)
)
SELECT *
FROM ATABLE A
LEFT JOIN BTABLE B ON A.AA=B.KEY1 AND A.BB=B.KEY2 AND A.CC=B.KEY3