All the columns in the where clause are indexed.
I was wondering if there was a more efficient way to write this and perform index only scans since the NOT IN predicate does a tablescan. Maybe a LEFT JOIN? Any input will be of great value.
SELECT ' ' FIRST_NAME,
' ' LAST_NAME,
A1.AGE,
A1.BUR,
A1.ACCT,
A1.ACCTRS,
A1.ACCTTL,
' ' EXAMID,
A1.OMBBRN,
A1.ACCTSRC
FROM SCHEMA_1.TABLE_1 A1
WHERE
ACCTSRC IN ('APPENDIX', 'TREASURY')
AND ACCTAI = 'A'
AND EXAMID
NOT IN
(SELECT NET_ID
FROM SCHEMA_2.TABLE_2
WHERE ALT_AGENCY = '854' AND NET_ID BETWEEN 'A%' AND 'ZZ%')
I was wondering if there was a more efficient way to write this and perform index only scans since the NOT IN predicate does a tablescan. Maybe a LEFT JOIN? Any input will be of great value.
SELECT ' ' FIRST_NAME,
' ' LAST_NAME,
A1.AGE,
A1.BUR,
A1.ACCT,
A1.ACCTRS,
A1.ACCTTL,
' ' EXAMID,
A1.OMBBRN,
A1.ACCTSRC
FROM SCHEMA_1.TABLE_1 A1
WHERE
ACCTSRC IN ('APPENDIX', 'TREASURY')
AND ACCTAI = 'A'
AND EXAMID
NOT IN
(SELECT NET_ID
FROM SCHEMA_2.TABLE_2
WHERE ALT_AGENCY = '854' AND NET_ID BETWEEN 'A%' AND 'ZZ%')