Mysql使用通配符提高搜索性能(%%) [英] Mysql Improve Search Performance with wildcards (%%)

查看:210
本文介绍了Mysql使用通配符提高搜索性能(%%)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我用于通过电子邮件搜索某人的查询

Below is a query I use for searching a person by email

  SELECT *
    FROM phppos_customers
    JOIN phppos_people ON phppos_customers.person_id = phppos_people.person_id
   WHERE deleted = 0
     AND email LIKE '%f%'
ORDER BY email ASC

在电子邮件上添加索引会加快查询速度吗?

Will adding an index on "email" speed up the query?

推荐答案

不,因为当你有一个前导通配符时,MySQL将无法使用索引。如果您将LIKE更改为'f%',则可以使用索引。

No, because MySQL will not be able to utilize the index when you have a leading wildcard. If you changed your LIKE to 'f%', then it would be able to use the index.

这篇关于Mysql使用通配符提高搜索性能(%%)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆