小编Bob*_*Bob的帖子

在JOIN中使用时,使用Containstable的Sql服务全文搜索非常慢!

我正在使用sql 2008全文搜索,我遇到严重的性能问题,具体取决于我如何使用Contains或ContainsTable.

下面是示例:(表一有大约5000条记录,table1上有一个覆盖索引,其中包含where子句中的所有字段.我试图简化语句,如果有语法问题,请原谅我.)

场景1:

select * from table1 as t1
where t1.field1=90
and   t1.field2='something'
and   Exists(select top 1 * from containstable(table1,*, 'something') as t2 
where t2.[key]=t1.id)
Run Code Online (Sandbox Code Playgroud)

结果:10秒(非常慢)

场景2:

select * from table1 as t1
join containstable(table1,*, 'something') as t2 on t2.[key] = t1.id
where t1.field1=90
and   t1.field2='something'
Run Code Online (Sandbox Code Playgroud)

结果:10秒(非常慢)

场景3:

Declare @tbl Table(id uniqueidentifier primary key)
insert into @tbl select {key] from containstable(table1,*, 'something')

select * from table1 as t1
where t1.field1=90
and   t1.field2='something'
and  Exists(select id from @tbl as tbl …
Run Code Online (Sandbox Code Playgroud)

sql-server performance full-text-search

12
推荐指数
3
解决办法
1万
查看次数

标签 统计

full-text-search ×1

performance ×1

sql-server ×1