I have a team member that is trying to run the following query...
SELECT
DISTINCT REGID,
TBL_02ND_NAME_DOB_SEX_ZIP.*
FROM
TBL_02ND_NAME_DOB_SEX_ZIP LEFT JOIN TBL_07TH_DOB_SSN
ON (TBL_02ND_NAME_DOB_SEX_ZIP.DOB_SSN = TBL_07TH_DOB_SSN.DOB_SSN
OR TBL_02ND_NAME_DOB_SEX_ZIP.NAME_DOB = TBL_07TH_DOB_SSN.NAME_DOB)
aside from the poor naming convention used, here's the issue:
He is trying to find records between two tables where either the DOB and SSN (concatenated field) match or the Name and DOB (concatentated field) match.
This query is currently taking 7 hours to run, the fields are varchar, and each table has about 50,000 records.
Any idea's on optimizing this query?
SELECT
DISTINCT REGID,
TBL_02ND_NAME_DOB_SEX_ZIP.*
FROM
TBL_02ND_NAME_DOB_SEX_ZIP LEFT JOIN TBL_07TH_DOB_SSN
ON (TBL_02ND_NAME_DOB_SEX_ZIP.DOB_SSN = TBL_07TH_DOB_SSN.DOB_SSN
OR TBL_02ND_NAME_DOB_SEX_ZIP.NAME_DOB = TBL_07TH_DOB_SSN.NAME_DOB)
aside from the poor naming convention used, here's the issue:
He is trying to find records between two tables where either the DOB and SSN (concatenated field) match or the Name and DOB (concatentated field) match.
This query is currently taking 7 hours to run, the fields are varchar, and each table has about 50,000 records.
Any idea's on optimizing this query?