I stands for intent lock, and they are always associated with hierarchies. Since the lock manager does not understand the physical structure, it is impossible for him to observe hierarchical locks, so the hierarchy is recreated into intent locks.
In your case, INSERT has an intent lock on the page. This means that he also got an X lock on the line on the page, which is normal behavior. Now he is trying to get a new IX lock, so you probably need to insert a line into another page. This would be the normal behavior of inserting into a table with several indexes: the first IX is on one of the indices (possibly clustered), and the second IX is on a non-clustered index.
The SELECT SELECT you say returns after 12 seconds, so its long query on a large dataset and plan probably chose a high degree of blocking, page blocking. SELECT has an S-lock on the page that INSERT wants to block IX, and wants the S-lock on which the INSERT has IX lock on the page.
This is a trivial dead end and is very easy to fix: make sure your SELECT does not need these S-locks. There is no INSERT error here. Not knowing what SELECt is, I cannot say for sure whether it is optimal or not. In my experience, almost always in SELECT, like this, there are many, many and many opportunities for improvement (eitehr SELECT or the circuit below it).
But, assuming SELECT is optimal, your easiest jailbreak card should include row versioning :
ALTER DATABASE <dbname> SET ALLOW_SNAPSHOT_ISOLATION ON; ALTER DATABASE <dbname> SET READ_COMMITTED_SNAPSHOT ON;
Update:
Actually, in the second reading, it is obvious that INSERT has locks in different tables (if you have not modified the XML, which looks manually edited here and there), so your explanation of how the insertion actions should be erroneous. INSERT is part of a transaction than at least two records: one of tables 1 and one of tables2. But this does not greatly change the problem or solution. It is true that you have the ability to split the two records in a transaction into separate transactions, but this is obviously the worst way.
Remus Rusanu
source share