In the past I always thought that select query would not blocks other insert sql. However, recently I wrote a query that takes a long time (more than 2 min) to select data from a table. During the select, a number of insert sql statements were timing out.
If select blocks insert, what would be the solution way to prevent the timeout without causing dirty read?
I have investigate option of using isolation snapshot, but currently I have no access to change the client’s database to enable the “ALLOW_SNAPSHOT_ISOLATION”.
Thanks
When it holds a lock on a resource that is mutually exclusive with one that the insert or update statement needs.
Under
readcommittedisolation level with no additional locking hints then theSlocks taken out are typically released as soon as the data is read. Forrepeatable readorserializablehowever they will be held until the end of the transaction (statement for a single select not running in an explicit transaction).serializablewill often take out range locks which will cause additional blocking over and above that caused by the holding of locks on the rows and pages actually read.