I have 2 tables.
TableA -> contains Address (2,00,00,000 rows). TableB -> contains standard pincodes (50,000 rows).
Objective is to derive standard pincodes for each address by searching each pincode in each address string.
Select A.ID, A.Address, B.Pincode
From TableA as A
Left join TableB as B
On A.Address like '℅'|| B.Pincode || '℅';
This is a product join of 2,00,00,000 X 50,000 records. And it is taking very long time to execute.
I have also tried alternatives like
Select A.ID, A.Address, B.Pincode
From TableA as A
Left join TableB as B
On Position(B.Pincode in A. Address) > 0;
Select A.ID, A.Address, B.Pincode
From TableA as A
Left join TableB as B
On INSTR(A.Address, B.Pincode ) > 0;
In TableA, Address is primary index. In TableB, Pincode is primary index. Pincode data is Alphanumeric. Address data is also Alphanumeric.
But still the execution takes a long time. Almost more than 30mins.
Please help me to optimize this query. Any kind of help is appreciated.
Thanks.