SQL Server : are transaction locking table for other users?

后端 未结 2 793
既然无缘
既然无缘 2021-01-27 23:41

Does a transaction lock my table when I\'m running multiple queries?

Example: if another user will try to send data in same time which I use transaction, what will happe

2条回答
  •  孤街浪徒
    2021-01-28 00:22

    You have to implement transaction smartly. Below are some performance related points :-

    1. Locking Optimistic/Pessimistic. In pessimistic locking whole table is locked. but in optimistic locking only specific row is locked.
    2. Isolation level Read Committed/Read Uncommitted. When table is locked it depends upon on your business scenario if it allowed you then you can go for dirty read using with NoLock.
    3. Try to use where clause in update and do proper indexing. For any heavy query check the query plan.
    4. Transaction timeout should be very less. So if the table is locked then it should throw error and In catch block you can retry.

    These are few points you can do.

提交回复
热议问题