Joining tables with an email address instead of an user ID

Years ago, my referrals table identified the recipient by just an email address. I have since upgraded the table to record the recipient’s first and last name. I use the query below to see if the recipient of a referral ever took the time to signup for their own account. But I’m starting to see the doing the join with an email address can be very slow. Any suggestions from you wise database gurus? Maybe I should remove the ability for my website members to see if a recipient has created their own account. The following will show all the referrals that user 717 has sent.

Thanks!

SELECT 
	r.rID, 
	r.firstName, 
	r.lastName, 
	r.recipientEmail, 
	r.testimonial, 
	r.dateArrived, 
	u.uID as registered 
FROM referrals r
LEFT JOIN users u 
on r.recipientEmail = u.email 
WHERE r.uID = 717
ORDER BY rID desc

do the join columns have indexes?

1 Like

That did the trick r937. I now have an index on the email column in the users table and the recipient column in the referrals table!

Thanks!