In the past I always thought that select quer开发者_如何学编程y 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 does a
Select
query block Inserts or Updates to the same or other table(s)?
When it holds a lock on a resource that is mutually exclusive with one that the insert or update statement needs.
Under readcommitted
isolation level with no additional locking hints then the S
locks taken out are typically released as soon as the data is read. For repeatable read
or serializable
however they will be held until the end of the transaction (statement for a single select not running in an explicit transaction).
serializable
will 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.
READPAST
might be what you're looking for - check out this article.
精彩评论