如何知道 SQL 全文索引填充何时完成? [英] How can I know when SQL Full Text Index Population is finished?

查看:36
本文介绍了如何知道 SQL 全文索引填充何时完成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在为针对测试 SQL Server 数据库运行的 ASP.NET 应用程序编写单元测试.即 ClassInitialize 方法创建一个包含测试数据的新数据库,ClassCleanup 删除该数据库.我们通过从代码运行 .bat 脚本来实现这一点.

We are writing unit tests for our ASP.NET application that run against a test SQL Server database. That is, the ClassInitialize method creates a new database with test data, and the ClassCleanup deletes the database. We do this by running .bat scripts from code.

被测试的类被赋予一个连接字符串,该字符串连接到单元测试数据库而不是生产数据库.

The classes under test are given a connection string that connects to the unit test database rather than a production database.

我们的问题是,数据库包含一个全文索引,需要用测试数据完全填充,以便我们的测试按预期运行.

Our problem is, that the database contains a full text index, which needs to be fully populated with the test data in order for our tests to run as expected.

据我所知,全文索引总是在后台填充.我希望能够:

As far as I can tell, the fulltext index is always populated in the background. I would like to be able to either:

  1. 使用同步(transact-SQL?)语句创建完全填充的全文索引,或
  2. 查看全文填充何时完成,是否有回调选项,或者我可以重复询问?

我目前的解决方案是在类初始化方法结束时强制延迟 - 5 秒似乎有效 - 因为我在文档中找不到任何内容.

My current solution is to force a delay at the end the class initialize method - 5 seconds seems to work - because I can't find anything in the documentation.

推荐答案

您可以使用 FULLTEXTCATALOGPROPERTY 查询状态(请参阅此处:http://technet.microsoft.com/en-us/library/ms190370.aspx).

You can query the status using FULLTEXTCATALOGPROPERTY (see here: http://technet.microsoft.com/en-us/library/ms190370.aspx).

例如:

SELECT
    FULLTEXTCATALOGPROPERTY(cat.name,'ItemCount') AS [ItemCount],
    FULLTEXTCATALOGPROPERTY(cat.name,'MergeStatus') AS [MergeStatus],
    FULLTEXTCATALOGPROPERTY(cat.name,'PopulateCompletionAge') AS [PopulateCompletionAge],
    FULLTEXTCATALOGPROPERTY(cat.name,'PopulateStatus') AS [PopulateStatus],
    FULLTEXTCATALOGPROPERTY(cat.name,'ImportStatus') AS [ImportStatus]
FROM sys.fulltext_catalogs AS cat

当您打开目录的属性对话框时,您可能还想使用 SQL Profiler 来监视 SQL Server Management Studio 发出的命令.该对话框包含人口状态指示,所有显示的信息均使用 T-SQL 进行查询.

You might also like to use SQL Profiler to monitor what commands SQL Server Management Studio issues when you bring up the properties dialog for the catalog. The dialog includes an indicatin of population status and all the information shown is queried using T-SQL.

这篇关于如何知道 SQL 全文索引填充何时完成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆