CREATE MULTISET TABLE KEY_T ,NO FALLBACK ,
NO BEFORE JOURNAL,
NO AFTER JOURNAL,
CHECKSUM = DEFAULT,
DEFAULT MERGEBLOCKRATIO
(
DW_CREAT_DT DATE FORMAT 'YYYY-MM-DD' NOT NULL,
VISITOR_ID INTEGER NOT NULL,
SRCE_VISITOR_ID VARCHAR(255) CHARACTER SET LATIN CASESPECIFIC NOT NULL,
SITE_NM VARCHAR(255) CHARACTER SET LATIN CASESPECIFIC NOT NULL,
EFF_DT DATE FORMAT 'YYYY-MM-DD' NOT NULL,
DOMN_ID CHAR(1) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL,
DW_LOAD_TS TIMESTAMP(0) NOT NULL,
DW_UPDT_TS TIMESTAMP(0) NOT NULL)
UNIQUE PRIMARY INDEX ( DW_CREAT_DT ,VISITOR_ID )
PARTITION BY RANGE_N(DW_CREAT_DT BETWEEN DATE '2010-08-01' AND '2099-12-31' EACH INTERVAL '1' DAY )
UNIQUE INDEX ( SRCE_VISITOR_D ,SITE_URL_NM ,DOMN_ID );
CREATE MULTISET TABLE CUST_T ,NO FALLBACK ,
NO BEFORE JOURNAL,
NO AFTER JOURNAL,
CHECKSUM = DEFAULT,
DEFAULT MERGEBLOCKRATIO
(
FIRST_DT DATE FORMAT 'yyyy-mm-dd' NOT NULL,
VISITOR_ID INTEGER NOT NULL,
CUST_ID INTEGER NOT NULL,
DOMN_ID CHAR(1) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL,
EFF_DT DATE FORMAT 'yyyy-mm-dd' NOT NULL,
DW_LOAD_TS TIMESTAMP(0) NOT NULL)
UNIQUE PRIMARY INDEX ( FIRST_DT ,VISITOR_ID,CUST_ID )
PARTITION BY RANGE_N(FIRST_DT BETWEEN DATE '2010-08-01' AND '2099-12-31' EACH INTERVAL '1' DAY );
Both the tables contains same number of rows. 1366380662
Here is my query
SELECT MIN(A.FIRST_DT), SRCE_VISITOR_ID, CUST_ID
FROM CUST_T A
INNER JOIN KEY_T B
ON A.FIRST_DT = B.DW_CREAT_DT
AND A.VISITOR_ID = B.VISITOR_ID
WHERE CUST_ID != 0
AND A.DOMN_ID = 'W'
AND B.DOMN_ID = 'W'
GROUP BY SRCE_VISITOR_ID, CUST_ID
Is there any other way to avoid all row scan ,even though there are 100% uniqueness.It is taking 15 minutes.
Please suggest any approach if there is any.