Skip Headers

# Batch Writing

Previous

Next

Batch writing can improve database performance by sending groups of `INSERT`, `UPDATE`, and `DELETE` statements to the database in a single transaction, rather than individually.

When used without parameterized SQL, this is known as dynamic batch writing.

When used with parameterized SQL (see "Parameterized SQL (Binding) and Prepared Statement Caching"), this is known as parameterized batch writing. This allows a repeatedly executed statement, such as a group of inserts of the same type, to be executed as a single statement and a set of bind parameters. This can provide a large performance benefit as the database does not have to parse the batch.

When using batch writing, you can tune the maximum batch writing size using `setMaxBatchWritingSize` method of the Login interface. The meaning of this value depends on whether or not you are using parameterized SQL:

- If you are using parameterized SQL (you configure your `Login` by calling `Login` method `bindAllParameters`), the maximum batch writing size is the number of statements to batch (default: 100).

- If you are using dynamic SQL, the maximum batch writing size is the size of the SQL string buffer in characters (default: 32000).

By default, TopLink does not enable batch writing because not all databases and JDBC drivers support it. Oracle recommends that you enable batch writing for selected databases and JDBC drivers that support this option (see "Configuring JDBC Options").

For a more detailed example of using batch writing to optimize write queries, see "Batch Writing and Parameterized SQL".

See Also

  Data Access Optimization
  Optimization