Marc A. Pelletier wrote:
Ilmari Karonen wrote:
mysql> SELECT page_namespace, page_title, page_id FROM page WHERE page_title LIKE '%fnord%' AND page_namespace=0; Empty set (4.90 sec)
mysql> SELECT page_namespace, page_title, page_is_redirect FROM page WHERE page_title LIKE '%fnord%' AND page_namespace=0; Empty set (30.56 sec)
That behavior is consistent with lack of indices, or the wrong *type* of indices, on the culpable columns forcing a seq scan.
That may well be what's happening, but if so, it's a bug in MySQL. Note that both of the queries have identical WHERE clauses. Given that said WHERE clauses match no rows, there's really no reason why any other part of the SELECT should make any difference. No rows is no rows.