Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NHibernate, Should i use ReadCommitted or ReadUncommited Transaction Isolation Level?

In a large business, should i use ReadCommitted or ReadUncommited Transaction Isolation Level by default when using NHibernate ?

By using ReadCommitted isolation, i've been facing in some locking on SELECT (Query) statements that become slow.

like image 855
Yoann. B Avatar asked Apr 03 '11 16:04

Yoann. B


People also ask

Which of the following is the strongest transaction isolation level?

Serializable is the highest isolation level that protects transactions from all types of concurrency phenomena.

Which of the following is used to set transaction isolation level?

To set the transaction isolation level, use an ISOLATION LEVEL level clause. It is not permitted to specify multiple ISOLATION LEVEL clauses in the same SET TRANSACTION statement. The default isolation level is REPEATABLE READ . Other permitted values are READ COMMITTED , READ UNCOMMITTED , and SERIALIZABLE .

Which isolation level has the highest risk of blocking on other transactions?

The SERIALIZABLE isolation level provides the most risk of blocking, but the lowest risk of lost data.

What mechanism do DBMSs commonly use to support transaction isolation?

Two-phase locking is the most common transaction concurrency control method in DBMSs, used to provide both serializability and recoverability for correctness.


2 Answers

Well, if you're using SqlServer and have problems with ReadCommitted timeouts/locks, this is easily explainable. You probably just have to run this:

ALTER DATABASE your_db SET SINGLE_USER WITH ROLLBACK IMMEDIATE ;
ALTER DATABASE your_db SET READ_COMMITTED_SNAPSHOT ON;
ALTER DATABASE your_db SET MULTI_USER;

try this and then retest your readcommitted approach. I would stick to it.

like image 141
MonkeyDeveloper Avatar answered Nov 07 '22 03:11

MonkeyDeveloper


The core of the question:

Should i use ReadCommitted or ReadUncommited Transaction Isolation Level ?

Well, they can give different results. So you're actually asking:

Can I use use different result-sets when that is faster?

The answer depends on the application, only you can decide. But in general customers, especially large businesses, are not very tolerant to this.

like image 44
Henk Holterman Avatar answered Nov 07 '22 03:11

Henk Holterman