how to optimize this query and increase its performance,
SELECT user.id,user.name,profile.info,score.amount
FROM user
LEFT JOIN profile ON profile.user_id = user.id AND profile.type = 'language'
LEFT JOIN score ON score.user_id = user.id AND score.type = 'total'
WHERE email = '[email protected]'
return results:
[id] => 1060225
[name] => john
[info] => En
[ammount] => 533
return results 2:
[id] => 1022805
[name] => karin
[info] =>
[ammount] => 11
tables:
users table
id name email
1 john [email protected]
2 karin [email protected]
3 Tom [email protected]
4 kit [email protected]
profile table
id user_id type info
1 1 is_admin true
2 1 language En
3 1 active true
4 2 is_admin false
1 1 like null
2 2 favorite null
3 3 is_admin false
4 2 experience 4
score table
id user_id type amount
1 1 daily 33
2 1 total 533
3 2 total 11
4 3 daily 44
thanks,
explain ...to find out where you need an index.explian select ...