Using delayed_commit to determine when log records are committed

A relational database is required to ensure a number of transaction properties, including atomicity, consistency, integrity and durability (known as the ACID properties). To ensure this, Adaptive Server adheres to the following rules; it:

How does delayed_commit improve performance?

set delayed_commit is a performance option suitable only for certain applications. It increases Adaptive Server’s performance for DML operations, (for example, insert, update, delete), but increases the risk of losing your data during a system failure. Performance gains depend on the application in use.

The types of applications that benefit from set delayed_commit typically include short transactions that are sent rapidly and serially to Adaptive Server. For example, a batch application that issues many insert statements, with each insert being a separate transaction.

You can enable delayed_commit for the session with the set command or the database with sp_dboption. The syntax for delayed_commit is:

set delayed_commit on | off | default

where on enables the delayed_commit option, off disables it, and default means the database-level setting takes effect.

The syntax for sp_dboption is:

sp_dboption database_name, 'delayed commit', [true | false]

where true enables delayed_commit at the database level, and false disables the delayed_commit option. Only the DBO can set this parameter.

After you enable set delayed_commit, the client application is notified of a successful commit before the corresponding log records are written to disk. This improves performance because all but the last log page is written to disk, alleviating contention on the last and active log page.

Consider the following before you enable set delayed_commit:

Changes to logging behavior

These are the changes to logging behavior when delayed_commit is enabled.

When a session implicitly or explicitly commits a transaction:

Risks of using delayed_commit

When set delayed_commit is enabled, Adaptive Server notifies the client application before the actual physical disk write is completed. Because of this, the application can perceive that the transaction is complete whether or not the physical disk write is successful. In the event of a system failure (disk errors, system crash, and so on), transactions that were not written to disk (transactions whose commit records were on the last log page) are not be present after recovery in spite of the application being notified they were committed.

Systems that require tight system interdependencies, such as through a messaging system used through RTDS, further complicate the consequences of using set delayed_commit.

There are two situations where applications can manage the risk:

Enabling set delayed_commit

You can enable set delayed_commit for a database or for a session, with the session setting over-ruling the database setting. This means that a session that enables the option has delayed_commit enabled regardless of the database setting.