假设我在不同的计算机上运行了两个SQL Server数据库,称之为MachineA
和MachineB
。
如果我执行了类似以下的查询
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
吗?或者是在这里发生更复杂的事情?
答案 0 :(得分:1)
查询优化器将根据链接的服务器驱动程序功能选择最佳计划。