Pages

Saturday, August 2, 2014

Automatically setting READ UNCOMMITTED isolation level in LINQ Contexts

We recently decided to set a READ UNCOMMITTED transaction isolation level for our queries to the database and we wanted to establish it at the Linq Context level so that all of our "Select" queries would apply it by default.

Reading table records in SQL temporarily locks them until the query finishes its execution and all the data is returned to the client. This locking may slow down the execution times of other competing queries on the same table. We had one particular query in one table that would normally take 10 - 12 seconds when executed alone. As soon as you had that same query competing with 35 other threads it would take anywhere between 60 to 120 seconds.