Bulk-load support

The Adaptive Server ODBC Driver supports bulk-load interface for fast insertions of large sets of rows to Adaptive Server. This interface is invoked when SQLBulkOperations is used with the SQL_ADD option and the EnableBulkLoad connection property is set. Two types of bulk loading are supported:

The following table guides you on what bulk-load option to use.

Table 3-1: Bulk-load option usage

Use case

Additional consideration

Bulk-load option to use

Note

Insertion of single or small number of rows.

None

Insertion of large batch of rows.

The batch is part of a multistatement transaction.

Array Inserts

Rows are inserted faster than when bulk load is disabled.

You cannot enable the Adaptive Server select into or bulkcopy option because of recoverability considerations.

Array Inserts

Rows are inserted faster than when bulk load is disabled.

The batch is a single transaction and the Adaptive Server select into/bulkcopy option is enabled.

Bulk Copy

Adaptive Server can use high-speed bulk copy, which is faster than array inserts. The performance of Bulk Copy is still slightly faster than Array Inserts even if high-speed bulk copy is not used.

See the Adaptive Server Enterprise Utility Guide for information about the implications of enabling select into/bulkcopy and the conditions under which high-speed or logged bulk copy is used.

EnableBulkLoad connection property

Enable or disable bulk-load support using the EnableBulkLoad connection property:

Alternatively, use the Sybase-specific SQL_ATTR_ENABLE_BULK_LOAD connection attribute to set EnableBulkLoad programmatically. The attribute accepts the same values as EnableBulkLoad. For example:

sr = SQLSetConnectAttr(hdbc, SQL_ATTR_ENABLE_BULK_LOAD, (SQLPOINTER)3, SQL_IS_INTEGER);

Performance considerations

Although this feature does not require special configuration on the server, a larger page size and network packet size significantly improves performance. Depending on the client memory, using larger batches also improves performance.

Limitations

Triggers are ignored on tables selected for bulk loading.

Enabling bulk load

StepsEnabling bulk load using the ODBC Data Source Administrator user interface

  1. Open the Data Source Name (DSN) Configure window from the ODBC Data Source Administrator.

  2. Select the Advanced tab.

  3. Select the appropriate option under “Enable Bulk Load.”

    The default value of EnableBulkLoad connection property is 0, which means insert commands are used.

StepsEnabling bulk load using the ODBC connection string

  1. Use SQLDriverConnect to specify a connection string.

  2. Set the EnableBulkLoad connection string property to 0, 1, 2, or 3, as appropriate. For example:

    Driver=AdaptiveServerEnterprise;server=server1;
    port=port1;UID=sa;PWD=;EnableBulkLoad=1;