Set isolation levels for maximum concurrency and data consistency

Isolation levels determine the level of locking that is required to execute a statement and the level of concurrency that is possible in your application. You need to choose isolation levels for your application that maximize concurrency and that also ensure data consistency.

Set the minimum isolation level that is possible to maximize concurrency. You can set isolation levels by statement, by connection, or at the driver level:
  • SQLSetConnectAttr() with the SQL_ATTR_TXN_ISOLATION attribute specified sets the isolation level at which all statements on a connection handle operate. This isolation level determines the level of concurrency that is possible, and the level of locking that is required to execute any statement on a connection handle.
  • SQLSetStmtAttr() with the SQL_ATTR_STMTTXN_ISOLATION attribute sets the isolation level at which an individual statement handle operates. (Although you can set the isolation level on a statement handle, setting the isolation level on the connection handle is recommended.) This isolation level determines the level of concurrency that is possible, and the level of locking that is required to execute the statement.
  • The TXNISOLATION initialization keyword sets the default isolation level for the Db2 ODBC driver.

Db2 ODBC uses resources that are associated with statement handles more efficiently if you set an appropriate isolation level, rather than leaving all statements at the default isolation level. This should be attempted only with a thorough understanding of the locking and isolation levels of the connected database server.