Packet Size

SAP HANA clients and the SAP HANA server encode data into packets for transfer between the clients and server.

A call into a client API method or function may require a different number of round trips depending on the packet size. For example, processing batch executes, fetching result sets, and transferring LOB data can require more than one round trip depending on the size of the data and the packet size. Increasing the packet size can reduce the number of round trips for these operations and can improve performance.

You can change the packet size at either the connection level or the statement level. The client uses the default connection level packet size of 1 MB for communication with the server. Changing the connection level packet size will apply to all statements created with the connection, but changing the statement packet size only applies to the statement. For example, if the statement needs to send a large amount of data to the server, increasing the statement packet size may increase the performance without impacting any other statements or needing to establish a connection with a different packet size.

Set the Packet Size for a Connection

Setting the packet size at the connection level has the same effect on all of its statements.

Set the Connection packetSize

Set the packet size for a connection using the packetSize connection property. See SQLDBC Connection Properties and JDBC Connection Properties for more information.

Set the Packet Size for a Connection in ODBC

As an alternative to the packetSize connection property, the following ODBC API can be used to set the connection packet size:
SQLSetConnAttr(hdbc, SQL_ATTR_PACKET_SIZE, (SQLPOINTER)packetSize, SQL_IS_INTEGER);

Set the Packet Size for a Statement

You can change the packet size for each statement created from a connection. The packet size specified for a statement overrides the connection level packet size for that statement and only affects that statement.

When setting the statement packet size, the value provided for packetSize must be greater than the default packet size for the connection or the connection's packetSize property (if specified), otherwise the default packet size or the specified packetSize is used.

Set the Packet Size for an ODBC Statement

Applications that use the ODBC driver can change the packet size for the statement using the following API:
SQLSetStmtAttr(hstmt, SQL_ATTR_STMT_PACKET_SIZE, (SQLPOINTER)packetSize, SQL_IS_INTEGER);

Set the Packet Size for a JDBC Statement

Applications that use the JDBC driver can use the following extension functions to set or get a packet size per statement:
  • com.sap.db.jdbc.Driver.setPacketSize( Statement statement, int packetSize )
  • com.sap.db.jdbc.Driver.getPacketSize( java.sql.Statement statement )

Set the Packet Size for a Python Statement

Applications that use the Python driver can use the following extension functions to set or get a packet size per cursor:
  • cursor.setpacketsize(packetSize)
  • cursor.getpacketsize()