字段类型是: 有这么两条sql语句,分别表现是: explain select email from email where enterpriseId=23684 and (email like 'aaa%'); +----+-------------+-------+------+---------------+------+---------+-------+------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+------+---------------+------+---------+-------+------+-------------+ | 1 | SIMPLE | email | ref | emailent,edf | edf | 5 | const | 6 | Using where |
explain select email from email where enterpriseId=23684 and (email like 'aaas%'); +----+-------------+-------+-------+---------------+----------+---------+------+------+--------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+-------+---------------+----------+---------+------+------+--------------------------+ | 1 | SIMPLE | email | range | emailent,edf | emailent | 770 | NULL | 2 | Using where; Using index | +----+-------------+-------+-------+---------------+----------+---------+------+------+--------------------------+
like两边都有%的情况,只会使用第一个条件的edf索引 mysql> explain select * from email where enterpriseId=23684 and (email like '%shihanasas%'); +----+-------------+-------+------+---------------+------+---------+-------+------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+------+---------------+------+---------+-------+------+-------------+ | 1 | SIMPLE | email | ref | edf | edf | 5 | const | 6 | Using where | +----+-------------+-------+------+---------------+------+---------+-------+------+-------------+
|
|