I have two tables, TableA and TableB.
TableA is a large dataset with thousands/millions of record and has a unique key (ID) and 3 alternate keys (NAME,SCHOOL,DATE). Table B is a smaller dataset with thousands of record and has no unique keys.
TableA --------- ID NAME SCHOOL DATE RECORD STATUS
TableB --------- NAME SCHOOL
Now, I need to join these two tables to get the list of unique IDs to be use in another query. Below is the sample query, but this took so long more hours to run.
SELECT a.ID AS ID_key, a.school, a.name
FROM TableA a, TableB b
WHERE a.name = b.name
AND a.school = b.school
AND a.status = 'Active'
Is there any way to optimize this query? Thanks in advance.