I have a speed problem when comparing two tables. Let's say I have the following tables.
Table A 14,000 records
name(varchar) , join_id(int)
Table b 54,209 records
second_name , join_id(int)
Now I want the find the rows which exists in table A , but not in B connected by joint_id Ordered by random ( sort of )
I tried the following :
SELECT a.name , b.second_name
FROM a
LEFT OUTER JOIN b ON a.joint_id = b.joint_id
WHERE b.joint_id IS NULL
LIMIT 0,10
The query took ages and is messing up the server , so my question is ;
Is there a faster way to accomplish this ?
EDIT : I removed the RAND() , this can be solved otherwise. But I still have the same problem. I will try out the suggestions below and see if I can improve the query time.