Tuning not in clause SQL
Hi Gurus,
Have an expensive query that uses 'not in'.
SELECT applicant_id,
Nvl(registration_site, 'UK') AS registration_site,
email,
Decode(withhold_third_party_info, 'Y', 0,
'N', 1,
0) AS withhold_third_party_info
FROM applicant
WHERE registration_site NOT IN ( 'JP', 'JX', 'YJ', 'SP',
'Q2', 'JL', 'KA', 'K2',
'KK', 'KX', 'Q1' );
When I checked distinct registration_site, there are 105 so can't use 'in' to eliminate 'not in'.
Execution Plan
----------------------------------------------------------
Plan hash value: 2341318952
-------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 16M| 598M| 191K (2)| 00:38:19 |
|* 1 | TABLE ACCESS FULL| APPLICANT | 16M| 598M| 191K (2)| 00:38:19 |
-------------------------------------------------------------------------------
Predicate Information (identified by operation id):
Have an expensive query that uses 'not in'.
SELECT applicant_id,
Nvl(registration_site, 'UK') AS registration_site,
email,
Decode(withhold_third_party_info, 'Y', 0,
'N', 1,
0) AS withhold_third_party_info
FROM applicant
WHERE registration_site NOT IN ( 'JP', 'JX', 'YJ', 'SP',
'Q2', 'JL', 'KA', 'K2',
'KK', 'KX', 'Q1' );
When I checked distinct registration_site, there are 105 so can't use 'in' to eliminate 'not in'.
Execution Plan
----------------------------------------------------------
Plan hash value: 2341318952
-------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 16M| 598M| 191K (2)| 00:38:19 |
|* 1 | TABLE ACCESS FULL| APPLICANT | 16M| 598M| 191K (2)| 00:38:19 |
-------------------------------------------------------------------------------
Predicate Information (identified by operation id):
0