0

Table_X 包含 7000 行 Table_Y 包含 1 000 000 行

此请求在 SQL Server2005 上运行速度很快,但在 SQL Server 2008 上需要 3 分钟

SELECT [Extent1].[ID] AS [ID]   
FROM [dbo].[TableX] AS [Extent1]
INNER JOIN [dbo].[TableY] AS [Extent2] ON [Extent1].[ID] = [Extent2].[Fk_Id]
WHERE (
    (
        [Extent2].[Fk_Id] IN (
            (
                SELECT [KEY]
                FROM CONTAINSTABLE([TableX], (Description), N'"PMI_Log"') [CT]
                )
            )
        )
    OR (
        [Extent2].[id] IN (
            (
                SELECT [KEY]
                FROM CONTAINSTABLE([TableY], (Description), N'"PMI_Log"') [CT]
                )
            )
        )
    )

已经重建索引、统计信息和目录。

2 个子查询(select..FROM ContainsTable...)需要 15 毫秒

执行计划说它需要 100% 的时间在表值函数 [FulltextMatch]

经过大量测试,当我在全文查询之间放置 OR 时,性能正在下降。

有人可以帮忙吗?

谢谢,

这个问题显然是同一个问题:SQL Server 2008 Full-Text Search (FTS)extreme slow when more than one CONTAINSTABLE in query

4

1 回答 1

2

这是SQL 2008 / 2008 R2的一个已知问题。它已在2008 SP1 CU92008 R2 CU4中修复。

作为一种解决方法,您可以将查询分成两部分和UNION结果。

SELECT 
   [Extent1].[ID] AS [ID]   
FROM 
   [dbo].[TableX] AS [Extent1]
   INNER JOIN [dbo].[TableY] AS [Extent2] 
   ON [Extent1].[ID] = [Extent2].[Fk_Id]
WHERE
   [Extent2].[Fk_Id] IN 
   (
      SELECT [KEY]
      FROM CONTAINSTABLE([TableX], (Description), N'"PMI_Log"') [CT]
   )

UNION

SELECT 
   [Extent1].[ID] AS [ID]   
FROM 
   [dbo].[TableX] AS [Extent1]
   INNER JOIN [dbo].[TableY] AS [Extent2] 
   ON [Extent1].[ID] = [Extent2].[Fk_Id]
WHERE
   [Extent2].[Fk_Id] IN 
   (
      SELECT [KEY]
      FROM CONTAINSTABLE([TableY], (Description), N'"PMI_Log"') [CT]
   )
于 2013-07-25T15:31:26.100 回答