200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > mysql in和or扫描全表_MySQL对OR条件查询不支持优化 会进行全表扫描

mysql in和or扫描全表_MySQL对OR条件查询不支持优化 会进行全表扫描

时间:2020-09-05 13:12:20

相关推荐

mysql in和or扫描全表_MySQL对OR条件查询不支持优化 会进行全表扫描

MySQL对OR条件查询不支持优化,会进行全表扫描:explain extended select * from like1 where name like 'abc%';例如:+----+-------------+-------+-------+---------------+-----------+---------+------+------+----------+-----------------------+| id | select_type | t...显示全部

MySQL对OR条件查询不支持优化,会进行全表扫描:

explain extended select * from like1 where name like 'abc%';

例如:

+----+-------------+-------+-------+---------------+-----------+---------+------+------+----------+-----------------------+

| id | select_type | table | type| possible_keys | key | key_len | ref| rows | filtered | Extra|

+----+-------------+-------+-------+---------------+-----------+---------+------+------+----------+-----------------------+

|1 | SIMPLE | like1 | range | nameindex | nameindex | 23 | NULL | 1 | 100.00 | Using index condition |

+----+-------------+-------+-------+---------------+-----------+---------+------+------+----------+-----------------------+

1 row in set, 1 warning (0.00 sec)

explain extended select * from like1 where name like 'abc%' or name > 1;

+----+-------------+-------+------+---------------+------+---------+------+------+----------+-------------+

| id | select_type | table | type | possible_keys | key| key_len | ref| rows | filtered | Extra |

+----+-------------+-------+------+---------------+------+---------+------+------+----------+-------------+

|1 | SIMPLE | like1 | ALL| nameindex | NULL | NULL | NULL | 1 | 100.00 | Using where |

+----+-------------+-------+------+---------------+------+---------+------+------+----------+-------------+

1 row in set, 2 warnings (0.01 sec)

大家还有那些对MySQL , OR方面的优化可以讨论?收起

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。