Postgres - How to prevent locking when parent table is updated whenever an insert/delete occurs in child table
My advice is to use a “deferred constraint trigger” to update the &quot;Products&quot; table whenever &quot;Items&quot; is modified.
Such triggers are AFTER triggers that are not run immediately after the statement, but at the very end of the transaction.
The advantage here is that the rows in &quot;Products&quot; won't be locked any longer than necessary, and your concurrency will be much better.