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 ...)需要15ms
执行计划表示在表值函数[FulltextMatch]
中占用100%的时间经过大量测试后,当我在FullText查询之间放置OR时,性能会下降。
有人可以帮忙吗?
THX,
这个问题显然是同一个问题:SQL Server 2008 Full-Text Search (FTS) extremely slow when more than one CONTAINSTABLE in query
答案 0 :(得分:2)
这是SQL 2008/2008 R2的a known issue。它已在2008 SP1 CU9和2008 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]
)