SQL Server 2008 Full Text Search – SLOW

走远了吗. 提交于 2019-12-14 02:33:46

问题


I'm using asp.net with SQL Server 2008 SP2

I have one table with Full Text Search Enabled.

My Hardware is: 2GHZ Quad-Core, 4GB RAM, SAS HDD.

The table has around 5 Million records, and its structure is:

Pages table:

ID (INT)
GroupID (INT)
GroupStart (bit)
Col1 varchar(900)
Col2 nvarchar(450)
Col3 nvarchar(450)
Col4 nvarchar(450)
Col5 nvarchar(450)

i have a fts index on the primary key ID.

I'm using the following query to search the table:

SELECT * FROM (  
SELECT * , ROW_NUMBER()  OVER(  ORDER BY  KEY_TBL.Rank DESC  ) AS RowNumber , COUNT(*) OVER() as TotalRows  
FROM Pages p  
INNER JOIN  
CONTAINSTABLE(Pages, *,N' FORMSOF (INFLECTIONAL, movies)') AS KEY_TBL  
ON p.ID = KEY_TBL.[KEY]  
WHERE  (p.GroupID IS NULL OR p.GroupStart = 1) 
) LS  
WHERE RowNumber BETWEEN 0 AND 10  
ORDER BY RowNumber ASC;

The query takes 1s to complete if total rows is about 500.

and takes 5s to complete if total rows is about 10,000.

and takes 60s to complete if total rows is about 100,000.

Any idea why is the query taking so long?

Is there something wrong in my query , sql server or is it a hardware problem?


回答1:


Full text search is only useful to search text within varchar or text fields, it will not speed up queries. You would need to add more indexes to the table to do that.

In general the query seems overly complicated, but you haven't explained what the query needs to do. I think the query needs to be optimized.




回答2:


Consider restricting number of matches returned by CONTAINSTABLE -> CONTAINSTABLE(Pages, *,N' FORMSOF (INFLECTIONAL, movies)', 100 )



来源:https://stackoverflow.com/questions/4078173/sql-server-2008-full-text-search-slow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!