I found in some legacy code (originally SQLServer 2008)
INSERT hints that I'm not sure to understand.
I have a table (storing many rows) and some procedures to fill this table. We insert rows one by one. One procedure call = one line inserted. Fine.
Sometimes (not always) SQL code looks like:
insert into my_table with(tablock, xlock) values(......)
Why tablock / xlock have been put here ?
What could be the benefit of locking a table when we insert only one line ?
Note this insert is embedded within a transaction with isolation serializable.
(I can imagine the benefit if we want to insert a bunch of records, ie. better performance).