SELECT COUNT( a.id ) FROM table_1 a LEFT JOIN table_2 b ON a.id = b.id LEFT JOIN table_3 y ON a.foo= y.id WHERE a.bar =1 AND a.field =3 AND b.mydate <= 1159438132 AND b.status =2 AND ( y.myfield IS NULL OR y.myfield !=2 ) id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE b ref status,mydate,id,mydate_2 status 1 const 10301 Using where 1 SIMPLE a eq_ref PRIMARY,bar,field PRIMARY 4 database_com.b.id 1 Using where 1 SIMPLE y eq_ref PRIMARY PRIMARY 4 database_com.a.foo 1 Using where