配置 network packet size 服务器配置选项Configure the network packet size Server Configuration Option

适用对象:是SQL Server 否Azure SQL 数据库 否Azure Synapse Analytics (SQL DW) 否并行数据仓库APPLIES TO: yesSQL Server noAzure SQL Database noAzure Synapse Analytics (SQL DW) noParallel Data Warehouse

本主题说明如何使用 SQL ServerSQL Server 中配置 SQL Server Management StudioSQL Server Management Studio network packet size Transact-SQLTransact-SQL服务器配置选项。This topic describes how to configure the network packet size server configuration option in SQL ServerSQL Server by using SQL Server Management StudioSQL Server Management Studio or Transact-SQLTransact-SQL. network packet size 选项设置整个网络中使用的数据包大小(以字节为单位)。The network packet size option sets the packet size (in bytes) that is used across the whole network. 数据包是具有固定大小的数据块区,用于在客户端与服务器之间传输请求和结果。Packets are the fixed-size chunks of data that transfer requests and results between clients and servers. 默认数据包大小为 4,096 个字节。The default packet size is 4,096 bytes.

备注

除非您确信能够提高性能,否则不要更改数据包的大小。Do not change the packet size unless you are certain that it will improve performance. 对于大多数应用程序而言,默认数据包大小为最佳数值。For most applications, the default packet size is best.

本主题内容In This Topic

开始之前Before You Begin

限制和局限Limitations and Restrictions

  • 对于加密连接,network packet size 的最大值为 16,383 字节。The maximum network packet size for encrypted connections is 16,383 bytes.

备注

如果启用了 MARS,则 SMUX 提供程序会在进行 SSL 加密之前向数据包添加 16 字节标头,从而将最大网络数据包大小减小到 16368 字节。If MARS is enabled, the SMUX provider will add a 16-byte header to the packet before SSL encryption, reducing the maximum network packet size to 16368 bytes.

建议Recommendations

  • 此选项是一个高级选项,仅应由有经验的数据库管理员或认证的 SQL ServerSQL Server 专业人员更改。This option is an advanced option and should be changed only by an experienced database administrator or certified SQL ServerSQL Server professional.

  • 如果应用程序进行大容量复制操作,或者发送或接收大量文本或图像数据时,数据包大小大于默认值可以提高效率,因为这样可以减少网络读写操作。If an application does bulk copy operations or sends or receives large amounts of text or image data, a packet size larger than the default might improve efficiency because it results in fewer network read-and-write operations. 如果应用程序发送和接收的信息量较少,则可以将数据包大小设置为 512 字节,这对大多数数据传输足够了。If an application sends and receives small amounts of information, the packet size can be set to 512 bytes, which is sufficient for most data transfers.

  • 在使用不同网络协议的系统上,将网络数据包大小设置为最常用协议使用的大小。On systems that are using different network protocols, set network packet size to the size for the most common protocol used. 如果网络协议支持更大的数据包,则使用 network packet size 选项可以提高网络性能。The network packet size option improves network performance when network protocols support larger packets. 客户端应用程序可以覆盖此值。Client applications can override this value.

  • 您还可以调用 OLE DB、开放式数据库连接 (ODBC) 和 DB-Library 函数来请求更改数据包大小。You can also call OLE DB, Open Database Connectivity (ODBC), and DB-Library functions request a change the packet size. 如果服务器无法支持所请求的数据包大小, 数据库引擎Database Engine 将向客户端发送警告消息。If the server cannot support the requested packet size, the 数据库引擎Database Engine will send a warning message to the client. 在某些环境下,更改数据包大小可能导致通信链接故障,如下所示:In some circumstances, changing the packet size might lead to a communication link failure, such as the following:

    Native Error: 233, no process is on the other end of the pipe.

SecuritySecurity

权限Permissions

默认情况下,所有用户都具备不带参数或仅带第一个参数的 sp_configure 的执行权限。Execute permissions on sp_configure with no parameters or with only the first parameter are granted to all users by default. 若要执行带两个参数的 sp_configure 以更改配置选项或运行 RECONFIGURE 语句,则用户必须具备 ALTER SETTINGS 服务器级别的权限。To execute sp_configure with both parameters to change a configuration option or to run the RECONFIGURE statement, a user must be granted the ALTER SETTINGS server-level permission. ALTER SETTINGS 权限由 sysadminserveradmin 固定服务器角色隐式持有。The ALTER SETTINGS permission is implicitly held by the sysadmin and serveradmin fixed server roles.

使用 SQL Server Management StudioUsing SQL Server Management Studio

配置 network packet size 选项To configure the network packet size option

  1. 在对象资源管理器中,右键单击服务器并选择 “属性”In Object Explorer, right-click a server and select Properties.

  2. 单击 “高级” 节点。Click the Advanced node.

  3. “网络” 下,选择 “网络数据包大小” 框的值。Under Network, select a value for the Network Packet Size box.

使用 Transact-SQLUsing Transact-SQL

配置 network packet size 选项To configure the network packet size option

  1. 连接到 数据库引擎Database EngineConnect to the 数据库引擎Database Engine.

  2. 在标准菜单栏上,单击 “新建查询”From the Standard bar, click New Query.

  3. 将以下示例复制并粘贴到查询窗口中,然后单击“执行” 。Copy and paste the following example into the query window and click Execute. 此示例说明了如何使用 sp_configurenetwork packet size 选项的值设置为 6500 字节。This example shows how to use sp_configure to set the value of the network packet size option to 6500 bytes.

USE AdventureWorks2012 ;  
GO  
EXEC sp_configure 'show advanced options', 1;  
GO  
RECONFIGURE ;  
GO  
EXEC sp_configure 'network packet size', 6500 ;  
GO  
RECONFIGURE;  
GO  
  

有关详细信息,请参阅 服务器配置选项 (SQL Server)版本的组合自动配置的最大工作线程数。For more information, see Server Configuration Options (SQL Server).

跟进:在配置网络数据包大小选项之后Follow Up: After you configure the network packet size option

该设置将立即生效,无需重新启动服务器。The setting takes effect immediately without restarting the server.

另请参阅See Also

RECONFIGURE (Transact-SQL) RECONFIGURE (Transact-SQL)
服务器配置选项 (SQL Server) Server Configuration Options (SQL Server)
sp_configure (Transact-SQL)sp_configure (Transact-SQL)