我应该使用 LIKE 查询有 400 万行的表吗 [英] should I use LIKE to query tables with 4 million rows

查看:34
本文介绍了我应该使用 LIKE 查询有 400 万行的表吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设计一个搜索表单,我想知道我是否应该提供使用 LIKE %search_string% 搜索最多 400 万行的表的可能性

I am designing a search form, and I am wondering whether should I give the possibility to search by using LIKE %search_string% for a table that is going to have up to 4 million rows

推荐答案

总的来说,我会拒绝.这是 全文索引.搜索字符串中的前导 % 将消除使用任何索引的可能性.

In general, I would say no. This is a good candidate for full-text indexing. The leading % in your search string is going to eliminate the possibility of using any indexes.

在某些情况下,等待是可以接受的和/或您不希望维护全文索引的额外管理开销,在这种情况下,您可以选择 LIKE.

There may be cases where the wait is acceptable and/or you do not want the additional administrative overhead of maintaining full-text indexes, in which case you might opt for LIKE.

这篇关于我应该使用 LIKE 查询有 400 万行的表吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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