Which IsolationLevel should you use?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to develop an application that connects
to a Microsoft SQL Server 2008 database. The application performs a database query within a transaction.
You need to ensure that the application can read data that has not yet beed commited by other transactions.
Which IsolationLevel should you use?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to develop an application that connects
to a Microsoft SQL Server 2008 database. The application performs a database query within a transaction.
You need to ensure that the application can read data that has not yet beed commited by other transactions.
Which IsolationLevel should you use?

A.
ReadUncommitted

B.
ReadCommitted

C.
RepeatableRead

D.
Unspecified

Explanation:
Unspecified A different isolation level than the one specified is being used, but the level cannot be determined.
When using OdbcTransaction, if you do not set IsolationLevel or you set IsolationLevel to Unspecified,
the transaction executes according to the isolation level that is determined by the driver that is being used.
Chaos The pending changes from more highly isolated transactions cannot be overwritten.
ReadUncommitted A dirty read is possible, meaning that no shared locks are issued and no exclusive locks are honored.
ReadCommitted Shared locks are held while the data is being read to avoid dirty reads, but the data can be changed before
the end of the transaction, resulting in non-repeatable reads or phantom data.
RepeatableRead Locks are placed on all data that is used in a query, preventing other users from updating the data.
Prevents non-repeatable reads but phantom rows are still possible.
Serializable A range lock is placed on the DataSet, preventing other users from updating or inserting rows into the dataset
until the transaction is complete.
Snapshot Reduces blocking by storing a version of data that one application can read while another is modifying the same data.
Indicates that from one transaction you cannot see changes made in other transactions, even if you requery.

IsolationLevel Enumeration
(http://msdn.microsoft.com/en-us/library/system.data.isolationlevel.aspx)

Isolation Levels in Database Engine
(http://msdn.microsoft.com/en-us/library/ms189122.aspx)

SET TRANSACTION ISOLATION LEVEL (Transact-SQL)
(http://msdn.microsoft.com/ru-ru/library/ms173763.aspx)

READ UNCOMMITTED
?????????, ??? ?????????? ????? ????????? ??????, ??????? ???? ???????? ??????? ????????????, ?? ??? ?? ???? ?????????????.
??????????, ?????????? ?? ?????? READ UNCOMMITTED, ?? ?????????? ??????????? ??????????, ????? ????????????? ?????????
??????????? ??????? ??????????? ?????? ??????? ????????????. ?????????? READ UNCOMMITTED ????? ?? ??????????? ????????????
????????????, ??????? ?? ????????? ?? ??????? ?????????? ????????? ?????????? ??????? ????????????, ?? ?? ??????????????? ??????.
????????? ????? ????????? ????????? ????????? ????????????????? ?????????, ??????? ?????????? ?????????????? ??????.
???????? ? ?????? ????? ???? ???????? ? ?? ????????? ?????????? ?????? ????? ?????????? ? ???????? ? ?????? ??????.

READ COMMITTED
?????????, ??? ?????????? ?? ????? ????????? ??????, ??????? ???? ???????? ??????? ????????????, ?? ??? ?? ???? ?????????????.
??? ????????????? ????????????? ??????. ?????? ????? ???? ???????? ??????? ???????????? ????? ?????????? ???????????? ?
??????? ??????????, ??????????? ???? ????? ????????????? ?????? ??? ???????????????? ??????. ???? ???????? ? SQL Server ?????????? ?? ?????????.

REPEATABLE READ
????????? ?? ??, ??? ?????????? ?? ????? ????????? ??????, ??????? ???? ????????, ?? ??? ?? ????????????? ??????? ????????????,
? ????? ?? ??, ??? ?????? ?????????? ?? ????? ???????? ??????, ???????? ??????? ???????????, ?? ?? ??????????.
??????????? ?????????? ??????????? ?? ???? ??????, ??????????? ????? ??????????? ??????????, ? ??????????? ?? ?? ??????????.
??? ????????? ?????? ??????????? ???????? ??????, ??????????? ??????? ???????????. ?????? ?????????? ????? ????????? ????? ??????,
??????????????? ???????? ?????? ??????????, ???????????? ? ??????? ??????????. ??? ????????? ??????? ?????????? ??????? ???????????
????? ????????? ????? ??????, ??? ???????? ? ?????????? ???????. ???????? ??, ??? ??????????? ?????????? ??????????? ?? ??????????
?????????? ? ?? ????????? ? ????? ?????? ??????????, ??????? ?????????? ????, ??? ??? ?????? ???????? ?? ????????? READ COMMITTED.
??????????? ???? ???????? ?????? ? ?????? ?????????????.

SNAPSHOT
????????? ?? ??, ??? ??????, ????????? ????? ??????????? ??????????, ????? ??????????? ?? ?????? ?????????? ? ??????? ??????, ?????????????? ? ?? ??????.
?????????? ?????????? ?????? ?? ?????????, ??????? ???? ????????????? ?? ?? ??????. ??????????, ??????????? ??????? ???????????, ?? ?????
????????? ??????, ????????????? ??????? ???????????? ????? ??????? ??????? ??????????. ????? ??????? ??????????? ?????? ????????? ????????????
? ?????????? ????????????? ?????? ??????????????? ?????? ?? ?????? ??????? ??????????.
?????????? ???????????? ??????? ?? ??????? ?????????? ??? ?????????? ??????, ?? ??????????? ??????? ?????????????? ???? ??????.
?????????? ?????? ???????????? ???????????? ??????? ?? ????????? ?????? ?????? ??????? ????????????. ??????????, ?????????????? ?????? ??????,
?? ????????? ?????????? ?????? ???????????? ???????????? ???????.

SERIALIZABLE
????????? ?????????:
– ?????????? ?? ????? ????????? ??????, ??????? ???? ???????? ??????? ????????????, ?? ??? ?? ???? ?????????????.
– ?????? ?????????? ?? ????? ???????? ??????, ??????????? ??????? ???????????, ?? ?? ??????????.
– ?????? ?????????? ?? ????? ????????? ????? ?????? ?? ?????????? ?????, ??????? ?????? ? ???????? ??????, ??????????? ???????????? ??????? ??????????, ?? ?? ??????????.
?????????? ????????? ??????????????? ? ????????? ???????? ?????, ??????????????? ???????? ?????? ????? ??????????, ??????????? ?? ????? ??????????.
?????????? ? ??????? ?????, ??????????????? ??????????? ??????? ??????????, ??????????? ??? ?????? ??????????. ??? ???????????,
??? ???? ?????-???? ?????????? ?????????? ??????????? ????????, ??? ????? ????????? ??? ?? ????? ????? ?????. ?????????? ????????? ???????????
?? ?????????? ??????????. ??? ????? ??????? ??????? ????????, ????????? ?? ????????? ????? ????????? ?????? ? ????????? ?????????? ?? ?????????? ??????????.
??-?? ??????? ???????????? ???? ???????? ????????????? ???????????? ?????? ??? ?????????????.



Leave a Reply 1

Your email address will not be published. Required fields are marked *