DROP DATABASE IF EXISTS bug17164; CREATE DATABASE bug17164; USE bug17164; DROP TABLE IF EXISTS t2; CREATE TABLE t2 ( id int(11) NOT NULL, name varchar(20), PRIMARY KEY (id), INDEX (name) ) ENGINE=InnoDB; INSERT INTO t2 VALUES (1,'A1'),(2,'A2'),(3,'B'); DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( id int(11) NOT NULL, fkey int(11), PRIMARY KEY (id), FOREIGN KEY (fkey) REFERENCES t2(id) ) ENGINE=InnoDB; INSERT INTO t1 VALUES (1,1),(2,2),(3,2),(4,3),(5,3); EXPLAIN SELECT COUNT(*) FROM t1 LEFT JOIN t2 ON t1.fkey = t2.id WHERE t2.name LIKE 'A%' \G EXPLAIN SELECT COUNT(*) FROM t1 LEFT JOIN t2 ON t1.fkey = t2.id WHERE (t2.name LIKE 'A%' OR FALSE) \G