sql - Why when I do a LEFT JOIN in MySQL does it not reduce the number of rows lookups? -


here query:

select sum(if(r.rating_rating <= 5 , r.rating_rating >= 4, 1, 0)), sum(if(r.rating_rating <= 4 , r.rating_rating >= 3, 1, 0)), sum(if(r.rating_rating <= 3 , r.rating_rating >= 0, 1, 0)) management amp left join wp_posts p on  amp.post_id = p.id left join wp_ratings r  on amp.post_id  = r.rating_postid , amp.editor_id = 2 

when use explain method this:

enter image description here

should last row in explain result same number first row (1056)?

why looking 14 767 rows? there way bring down 1056?

a left join without index read through rows in second table , move matching rows cache (the "join buffer" see there) before presenting data.

the way remove add index on rating_postid wp_ratings can use index seek rows needs. nb: still pull more 1,056 rows if there more 1 rating per post.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -