I have this query:
SELECT f.uid, fi.status FROM friends f
LEFT JOIN friends_invitations fi ON f.fid = fi.fid
WHERE (f.uid = 2 OR fi.uid = 2)
The above query is correct, however performance-wise it's scanning all rows in the friends table, and ignoring the f.uid index in the WHERE clause, despite fid and uid being indexes in BOTH tables.
Basically I want the optimal approach to retrieve a user that exists either in Friends or Friends Invitations table using the 'uid' field.
Any ideas/suggestions?