从 SQL Server 2008 R2 获取大约 7Mb 的数据到客户端大约需要 5 秒。该机是比较强大的 AMD 12 Core,64Gb RAM,Windows Server 2008,2 10Gbit 卡。在服务器上运行 select 甚至更慢,然后从客户端运行。将 7Mb 文件从该服务器复制到本地工作站大约需要 500 毫秒。
这是一个小型复制器:
--create test table for reproducer
CREATE TABLE [dbo].[Test_Speed](
[ED] [datetime] NULL
) ON [PRIMARY]
--fill test table with data, insert took 3:51 mins
declare @r int
set @r = 1
while (@r < 830000)
begin
insert into [CDB_ODS].[dbo].[Test_Speed] select getdate()
set @r = @r+1
end
--select all records, roughly 7Mb. 4 secs if run on the client, 5 secs on the server (1.4Mb sec)
select ed from [dbo].[Test_Speed]
/*
SELECT on CLIENT
SQL Server parse and compile time:
CPU time = 0 ms, elapsed time = 0 ms.
Table 'Test_Speed'. Scan count 1, logical reads 1833, physical reads 0, read-ahead reads 0,
lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
SQL Server Execution Times:
CPU time = 281 ms, elapsed time = 4020 ms.
SQL Server parse and compile time:
CPU time = 0 ms, elapsed time = 0 ms.
SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 0 ms.
--- SELECT on SERVER
SQL Server parse and compile time:
CPU time = 0 ms, elapsed time = 0 ms.
(829999 row(s) affected)
Table 'Test_Speed'. Scan count 1, logical reads 1833, physical reads 0, read-ahead reads 0,
lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
SQL Server Execution Times:
CPU time = 328 ms, elapsed time = 5369 ms.
SQL Server parse and compile time:
CPU time = 0 ms, elapsed time = 0 ms.
SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 0 ms.
*/