credit table and validtransaction table have million record data from year 2008 onwards.
We are doing a migration. So I need to find out the credittypeids which are no longer in use after 2017 (periodseq=1055), so that these need not be migrated.
This is the query and the >= part is resulting in huge cost. Please suggest an alternative.
SELECT CREDITTYPEID
FROM CREDITTYPE ct
WHERE NOT EXISTS
(SELECT 1
FROM CREDIT C
WHERE C.PERIODSEQ>=1055
AND C.CREDITTYPEID=CT.CREDITTYPEID
);