在数据库上执行字符串搜索的最佳方法

时间:2022-09-15 19:47:19

I am looking for the best programming practice to perform a text based search on a database. We currently use multiple LIKE '%Keyword%' queries that are quite slow on our server as it can go through anywhere from 50-75k records. I have looked into Full Text Search a bit and was wondering if that is the best solution or if there are others that exist.

我正在寻找最好的编程实践来在数据库上执行基于文本的搜索。我们目前使用多个LIKE'%Keyword%'查询,这些查询在我们的服务器上非常慢,因为它可以在50-75k记录中查看。我有点研究全文搜索,并想知道这是否是最佳解决方案,或者是否存在其他解决方案。

Specifics: I am searching for multiple keywords or phrases in a table with a large list of records with text. I am performing an OR search for keywords and phrases.

细节:我在一个表中搜索多个关键字或短语,其中包含大量带文本的记录。我正在搜索关键字和短语的OR搜索。

1 个解决方案

#1


1  

Which database system do you use? Without this information it is pretty difficult to answer accurately. For SQL Server Full-Text search is a pretty good solution, like gh9 already said.

你使用哪个数据库系统?没有这些信息,很难准确回答。对于SQL Server全文搜索是一个非常好的解决方案,就像gh9已经说过的那样。

Indexing the columns - like suggested - wouldn't be a solution, since you start your search term with an wildcard. So the keyword could not be used as a "Seek Predicate" Seek Predicate

索引列(如建议的那样)不是解决方案,因为您使用通配符开始搜索词。所以关键字不能用作“寻求谓词”寻求谓词

#1


1  

Which database system do you use? Without this information it is pretty difficult to answer accurately. For SQL Server Full-Text search is a pretty good solution, like gh9 already said.

你使用哪个数据库系统?没有这些信息,很难准确回答。对于SQL Server全文搜索是一个非常好的解决方案,就像gh9已经说过的那样。

Indexing the columns - like suggested - wouldn't be a solution, since you start your search term with an wildcard. So the keyword could not be used as a "Seek Predicate" Seek Predicate

索引列(如建议的那样)不是解决方案,因为您使用通配符开始搜索词。所以关键字不能用作“寻求谓词”寻求谓词