链接服务器连接在哪里执行计算?

时间:2012-06-22 12:12:51

标签: sql-server join

假设我在不同的计算机上运行了两个SQL Server数据库,称之为MachineAMachineB

如果我执行了类似以下的查询

SELECT
    [Store].[Name] AS [Store Name],
    [Employee].[Name] AS [Employee Name],
    SUM([Sale].[Amount]) AS [Total Sales]
FROM [MachineA].[DatabaseA].[dbo].[Sales] AS [Sale]
INNER JOIN [MachineB].[DatabaseB].[dbo].[Employees] AS [Employee]
ON [Sale].[EmployeeId] = [Employee].[EmployeeId]
INNER JOIN [MachineB].[DatabaseB].[dbo].[Stores] AS [Store]
ON [Employee].[StoreId] = [Store].[StoreId]
GROUP BY [Store].[Name], [Employee].[Name]

我们假设查询在MachineA上运行,实际执行的工作在哪里? MachineA执行所有读取并将行发送到MachineB JOIN吗?或者是在这里发生更复杂的事情?

1 个答案:

答案 0 :(得分:1)

查询优化器将根据链接的服务器驱动程序功能选择最佳计划。