我有一个包含字符串字段 s 的表格,我想运行此查询:
SELECT * FROM mytable WHERE s = LEFT("färgkört", CHAR_LENGTH(s));
它的解释清楚地表明我没有在该字段上使用索引:
+----+-------------+--------------+------+---------------+------+---------+------+--------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------------+------+---------------+------+---------+------+--------+-------------+
| 1 | SIMPLE | mytable | ALL | NULL | NULL | NULL | NULL | 766554 | Using where |
+----+-------------+--------------+------+---------------+------+---------+------+--------+-------------+
有没有办法优化像这样的查询?