Snapshot isolation is enabled or disabled for a database using the allow_snapshot_isolation option. When the option is set to On, row versions are maintained in the temporary file, and connections are allowed to use any of the snapshot isolation levels. When this option is set to Off, any attempt to use snapshot isolation results in an error.
Enabling a database to use snapshot isolation can affect performance because copies of all modified rows must be maintained, regardless of the number of transactions that use snapshot isolation. See Cursor sensitivity and isolation levels.
The following statement enables snapshot isolation for a database:
SET OPTION PUBLIC.allow_snapshot_isolation = 'On'; |
The setting of the allow_snapshot_isolation option can be changed, even when there are users connected to the database. When you change the setting of this option from Off to On, all current transactions must complete before new transactions can use snapshot isolation. When you change the setting of this option from On to Off, all outstanding transactions using snapshot isolation must complete before the database server stops maintaining row version information.
You can view the current snapshot isolation setting for a database by querying the value of the SnapshotIsolationState database property:
SELECT DB_PROPERTY ( 'SnapshotIsolationState' ); |
The SnapshotIsolationState property has one of the following values:
On Snapshot isolation is enabled for the database.
Off Snapshot isolation is disabled for the database.
in_transition_to_on Snapshot isolation will be enabled once the current transactions complete.
in_transition_to_off Snapshot isolation will be disabled once the current transactions complete.
When snapshot isolation is enabled for a database, row versions must be maintained for a transaction until the transaction commits or rolls back, even if snapshots are not being used. Therefore, it is best to set the allow_snapshot_isolation option to Off if snapshot isolation is never used.
Discuss this page in DocCommentXchange.
|
Copyright © 2010, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.0 |