Skip to content

Tag: transactions

PostgreSQL: deadlock without a transaction

I have a route (in a node JS app) that inserts and updates some data in a PostgreSQL database (version 13). In pseudo-code, here are all queries that are done in sequential order: On some instances of the app without that much traffic that writes on their own table, I have many deadlocks. I don’t understand why since there is

SQL – on which context do SELECT…FOR UPDATE and UPDATE work?

I would like to have a question about data contexts on which do the transaction operate with different commands. Are there any differences in SELECT…FOR UPDATE and UPDATE in terms of contexts of data? What I mean by this: if I run the following transaction (pseudo-code): What this actually does is that it locks the user in exclusive mode and

Transaction Mode in SQL

I was reading through the BNF grammar for transaction statements and saw that transaction modes can be specified directly in the START TRANSACTION statement. Is there a difference in specifying transaction modes in START TRANSACTION vs SET TRANSACTION statements? Answer No difference. The SET TRANSACTION setting only affects the single next transaction to be started. Use SET SESSION to set