Basically, I have a table with a primary key column with two fields (memberid, messageid), and I have a saved proc that inserts a new row into this table.
Now I am checking if a row exists with PK and inserts, if not, but I have already encountered a situation where the row was inserted by another process right after the check and before the actual insert, so I am thinking of an alternative path.
I DO NOT want to use transactions for performance reasons, so I thought about including INSERT in try-catch and skipping validation altogether. If the row already exists, the insert will not be executed, but the catch will be disabled, which is OK.
My question is - is it throwing a mistake and catching it with an expensive operation?
performance sql-server sql-server-2008
Andrey
source share