Crusader Posted November 6, 2008 Share Posted November 6, 2008 Please help me figure out what index to put in for this. I see this in all my slow logs since it doesn't use indexes. It's called on pretty much every page on my forum. SELECT moderator.mid as is_mod, moderator.allow_warn, m.*, g.* FROM ibf_members m LEFT JOIN ibf_groups g ON (g.g_id=m.mgroup) LEFT JOIN ibf_moderators moderator ON (moderator.member_id=m.id OR moderator.group_id=m.mgroup ) WHERE m.id=592; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE m const PRIMARY,id PRIMARY 3 const 1 1 SIMPLE g const PRIMARY PRIMARY 4 const 1 1 SIMPLE moderator ALL group_id,member_id NULL NULL NULL 30 I can't, for the life of me, figure this out. Quote Link to comment https://forums.phpfreaks.com/topic/131604-indexes-and-left-joins/ Share on other sites More sharing options...
luca200 Posted November 6, 2008 Share Posted November 6, 2008 I think you actually have indexes on group_id and member_id, otherwise your question would not make a sense. Try splitting last join in two: the first on member_id and the second on group_id Quote Link to comment https://forums.phpfreaks.com/topic/131604-indexes-and-left-joins/#findComment-683543 Share on other sites More sharing options...
fenway Posted November 6, 2008 Share Posted November 6, 2008 It won't use proper indexes with an OR in the join condition. Quote Link to comment https://forums.phpfreaks.com/topic/131604-indexes-and-left-joins/#findComment-683719 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.