First of all: What you try is close to impossible - I don't know of an RDBMS, that can escalate INSERT
s into one table into UPDATE
s of another with "ABSOLUTELY NO LOCKING".
That said:
- my first point of research would be, whether the schema could be overhauled to optimize this hotspot away.
- if this cannot be achieved, you might want to look into making
table2
an in-memory type that can be recreated from existing data (such as keeping snapshots of it together with the max PK oftable1
and rolling forward if a DB restart is required). Since you need to update all rows on everyINSERT
intotable1
it cannot be very big. - Next point of research would be to put the
INSERT
and theUPDATE
into a stored procedure, that is called by the insertion logic. This would make a runaway situation with the resulting locking hell on catchup much less likely.