Open 2 windows in SQLServer 2014 Management Studio connected to a 2014 DB.
In 1st window:
SELECT * FROM categorytypes WHERE id = 12 Output:
ID DESCRIPTION ORDER --------------------- 12 Electronics 20 Then:
begin tran UPDATE CategoryTypes SET [order] = 20 WHERE id = 12 Now go to other window (Ctrl+N):
SELECT * FROM CategoryTypes The query will execute indefinitely until 1st window tran is committed or roll-backed. That's fine because ID=12 row is locked.
SELECT * FROM CategoryTypes WHERE ID <> 12 That works fine.
SELECT * FROM CategoryTypes WHERE Description = 'MEN' Here it is problem, why the hell this query should execute indefinitely, we know that ID=12 has description 'Electronics'.
In a large application where huge DML process and select operation is done simultaneously on same table, this kind of locking mechanism wont allow to do these 2 things on same time on different set of records.
In Oracle this kind of use case works, as long as locked (dirty row) is not part of result set.
Guys, is there any way to avoid this, kind of Oracle locking mechanism? I don't want to use NOLOCK, or set my transaction to READ UNCOMMITTED.
Thanks.