以下是我的查询。在sql server中运行需要4分钟,通过.net代码需要1个多小时。请为此查询建议备用解决方案。
SELECT DISTINCT
REPLACE(REPLACE(
CASE
WHEN (CHARINDEX('/', REVERSE(URL), 1) = 1)
THEN LEFT(URL, LEN(URL) - 1)
ELSE URL
END, 'http://', ''), 'www.', '') AS URL,
NULL AS [source],
REPLACE(REPLACE(
CASE
WHEN (CHARINDEX('/', REVERSE(TargetURL), 1) = 1)
THEN LEFT(TargetURL, LEN(TargetURL) - 1)
ELSE TargetURL
END, 'http://', ''), 'www.', '') AS TargetURL,
NULL AS [target],
PageAuthority AS Authority,
1 AS [isInternal]
FROM [Internal](nolock)
WHERE Domain_ID = 2
AND NoofDomainsLinkingtothisPage > 1
AND REPLACE(REPLACE(
CASE
WHEN (CHARINDEX('/', REVERSE(URL), 1) = 1)
THEN LEFT(URL, LEN(URL) - 1)
ELSE URL
END, 'http://', ''), 'www.', '')
IN (SELECT DISTINCT URL FROM #tempCalAuthTable11(NOLOCK))--864
AND REPLACE(REPLACE(
CASE
WHEN (CHARINDEX('/', REVERSE(TargetURL), 1) = 1)
THEN LEFT(TargetURL, LEN(TargetURL) - 1)
ELSE TargetURL
END, 'http://', ''), 'www.', '')
IN (SELECT DISTINCT URL FROM #tempCalAuthTable11(NOLOCK))
以下是执行计划详情。