0

假设我有两个 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执行所有读取并将行发送到MachineBfor JOINing?还是这里发生了更复杂的事情?

4

1 回答 1

1

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

于 2012-06-22T12:16:56.630 回答