我应该使用 LIKE 查询有 400 万行的表吗 [英] should I use LIKE to query tables with 4 million rows
问题描述
我正在设计一个搜索表单,我想知道我是否应该提供使用 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屋!