SQL 搜索文章 的优化问题
SQL 搜索文章 的优化问题
sql server 数据库
搜索文章列表
article表
字段:
id (int)
title(nvarchar)
content (text)
create (datetime)
content 的内容非常多,现在列表里面有1000片文章,content的内容是通过编辑器转义存储在数据库字段里面的
title 的内容稍微少,
现在搜索'测试' 这两个字 我自己写的一些查询测试
select * from Article where patindex('%测试%',Content)>0 or
patindex('%测试%',Title)>0 (速度较慢)
select * from Article where Content like '%测试%' or Title like '%测试%' (速度较慢)
select * from Article where charindex('测试',Content,0)>0 or charindex('测试',Title,0)>0 (速度很快,但是数据不准确)
听说还可以用正则表达式搜索的,但是我没有用过,也搜索不出来结果,所以就没贴出来.
求高手指教,1000多条数据,很慢啊!!!!