Select top 1 with UPDLOCK and READPAST sets exclusive lock on the entire table

后端 未结 3 738
感动是毒
感动是毒 2021-01-05 04:44

I\'m using the UPDLOCK and READPAST sql hints in a stored procedure in order to implement a sort of a table queue (I say a sort because I select top 1500 instead of a top 1,

3条回答
  •  失恋的感觉
    2021-01-05 05:41

    I think your problem is indexing. Make sure you have the proper indexes on your table and make sure your queries always use that index. Having no, or the incorrect index can make SQL Server take a page lock or a table lock, which invalidates the whole model.

提交回复
热议问题