DarkConsultant
Programmer
Hi,
I have two tables, one contains contact information (count = 4500 records) and has a Primary Key of UIN. The other is a members table containing contacts' UIN's (count = 2000 records).
I needed to get all the UINs from the contacts table where the same UIN is NOT in the members table so ...
The quickest query was "SELECT UIN FROM contact WHERE UIN NOT IN (SELECT DISTINCT MemberUIN FROM members)" with a response time of .. wait for it .. 12 seconds.
So then I tried removing the subquery and creating the 'IN' part myself ...
$temp=array();
while($row=mysql_fetch_array($temp,MYSQL_ASSOC)){$x[]=$row['MemberUIN'];}
New query -
"SELECT UIN FROM contact WHERE UIN NOT IN (".implode(",",$x)")";
Response time .. wait for it .. less than .2 seconds (cant measure smaller).
Am I doing something very wrong here?
TIA
David
DarkConsultant
Live long and prosper \\//
I have two tables, one contains contact information (count = 4500 records) and has a Primary Key of UIN. The other is a members table containing contacts' UIN's (count = 2000 records).
I needed to get all the UINs from the contacts table where the same UIN is NOT in the members table so ...
The quickest query was "SELECT UIN FROM contact WHERE UIN NOT IN (SELECT DISTINCT MemberUIN FROM members)" with a response time of .. wait for it .. 12 seconds.
So then I tried removing the subquery and creating the 'IN' part myself ...
$temp=array();
while($row=mysql_fetch_array($temp,MYSQL_ASSOC)){$x[]=$row['MemberUIN'];}
New query -
"SELECT UIN FROM contact WHERE UIN NOT IN (".implode(",",$x)")";
Response time .. wait for it .. less than .2 seconds (cant measure smaller).
Am I doing something very wrong here?
TIA
David
DarkConsultant
Live long and prosper \\//