question

cstephen avatar image
cstephen asked

is it adviseable to use with(readpast) in delete statement

delete from stock with(readpast) where guid=@guid Is it advisable to use with(readpast) locking hints in delete statment. exactly what it will do in delete operations
performance-tuning
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Kev Riley avatar image
Kev Riley answered
Using this hint is not advisable in the same sense that using most table hints is not advisable - you should only be doing this as where you really need to change the default behaviour of the query optimizer, and you know the full consequences not only on your transaction, but on others too. In the case where you want to process a queue of items, in your case deleting them, it could be seen that using this hint is 'acceptable' as any locked rows would be skipped and presumably deleted by the next pass of the queue. But I'd want to know why the rows to be deleted where being locked for so long that it was causing blocking on the delete. It might be a symptom of a design smell. Also think of the application as a whole - what should happen if you issue the delete command, and the row isn't deleted due to READPAST, but some other data, or part of the application expected the delete to work.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

cstephen avatar image
cstephen answered
for user running stock items,whose having negative stock.suppose negative stock stock there means,it is inserted in stock table.after following guid,once inserted records in the table will be deleted.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.