我有一些全文目录,从前一段时间,查询时间真的变慢了,到目前为止我发现的唯一解决方案是重建目录,有时一天不止一次使用命令:
ALTER FULLTEXT CATALOG TABLE1 REBUILD
为什么需要重建目录?这个问题还有其他解决方案吗?
运行重建命令后,查询是即时的,当减速可能需要几秒钟或一分钟。
我的目录已由此代码创建:
DECLARE @catalog VARCHAR(255)
DECLARE @pkCatalog VARCHAR(255)
SET @catalog = 'TABLE1'
SET @pkCatalog = 'PK_' + @catalog
EXEC sp_fulltext_database 'enable'
EXEC sp_fulltext_catalog @catalog, 'create'
EXEC sp_fulltext_table @catalog, 'create', @catalog, @pkCatalog
----------------------------------- INICIO CURSOR: cursorColumn
DECLARE cursorColumn CURSOR
FOR
select name from syscolumns where id=object_id(@catalog) and xtype = 167
FOR READ ONLY
OPEN cursorColumn
DECLARE @colName SYSNAME
FETCH NEXT FROM cursorColumn INTO @colName
WHILE (@@fetch_status <> -1)
BEGIN
EXEC sp_fulltext_column @catalog,@colName,'add'
FETCH NEXT FROM cursorColumn INTO @colName
END
CLOSE cursorColumn
DEALLOCATE cursorColumn
------------------------------------- FIM CURSOR: cursorColumn
EXEC sp_fulltext_table @catalog,'activate'
EXEC sp_fulltext_table @catalog, 'Start_change_tracking'
EXEC sp_fulltext_table @catalog, 'Start_background_updateindex'
GO