I have a database that keeps records on the issue and failure of an item.
Currently, the database is poorly desisned; therefore I'm performing queries
to break the data into normalized tables and attempting to perform a "left
join" query to build a cross-reference table.
The left join query is currently taking nearly 2 hours for MySQL to process,
using Navicat as a front-end. My system specs are 1.4Mhz Pentium Processor
with 1GB of RAM running on Windows XP. The first table "CDID" has the
following layout:
TblID INT 11 Primary
Holder ID INT 11 Index
CD Serial VARCHAR 26 Index
Fail Rsn VARCHAR 5
CD Type CHAR 3
Holder ID-CD Serial as Normal Index
This table contains 6,671,610 records.
The second table "TranTBL"
CDTblID INT 11 Primary
Holder ID INT 11 Index
CD Serial VARCHAR 26 Index
CDExpire Dt Date 0
Expire Rsn VARCHAR 4
Fail Dt Date 0
CardType CHAR 3
Issue Dt Date 0
Expire Dt Date 0
Race CHAR 2
Gender CHAR 2
Marital Status CHAR 2
Ethnicity VARCHAR 2
Height Smallint 6
Weight Smallint 6
DOB Date 0
Holder ID-CD Serial as Normal Index
This table contains 5,879,210 records.
My sql code for the query is as follows:
SELECT
`CDID`.`Holder ID`,
`CDID`.`CD Serial`,
`CDID`.`Fail Rsn`,
`TranTBL`.`Fail Dt`,
`TranTBL`.`Issue Dt`,
`TranTBL`.`Expire Dt`
FROM
`CDID`,
`TranTBL`
WHERE
`CDID`.`Holder ID`= `TranTBL`.`Holder ID` AND
`CDID`.`CD Serial`= `TranTBL`.`CD Serial`
Explain Provides the following:
Table Type Possible keys key
key length ref
rows extra
IDCD All Holder ID-CD Serial Null
8 Null
6,671,610 Null
TranTBL ref Holder ID-CD Serial Holder ID-CD Serial 8
IDCD.Holder ID, IDCD.CD Serial 1 Using where
Thanks in advance for any assistance or suggestions that you can offer.
Trent