'Why mysql fulltext search scan entire table when using "OR"?

My table A is

CREATE TABLE `a` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `content` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`),
  FULLTEXT KEY `f_c` (`content`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;

My table B is

CREATE TABLE `b` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `content` varchar(255) DEFAULT NULL,
  `a_id` int DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `i_a` (`a_id`),
  FULLTEXT KEY `f_t` (`content`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

My query is

EXPLAIN 
  SELECT * FROM a 
  LEFT JOIN b ON a.id = b.a_id 
  WHERE MATCH(a.content) AGAINST ("foo") 
          OR MATCH(b.content) AGAINST ("foo");

And the result is mysql scan all rows in table A. Why is it? How to solve it?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source