Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change transaction isolation level globally?

How can I change the default transaction isolation level for the database?

The postgres docs show how to change it per transaction and per session - but not how to alter the default for the database or cluster.

In MySQL the operation is

SET GLOBAL TRANSACTION ISOLATION LEVEL READ UNCOMMITTED ;

Is there an equivalent for PostgreSQL?

like image 863
Ulad Kasach Avatar asked Oct 17 '25 13:10

Ulad Kasach


1 Answers

Per the contents of this book indexed by google

One can change the whole default database isolation level to SERIALIZABLE as follows

ALTER DATABASE <DATABASE NAME> SET DEFAULT_TRANSACTION_ISOLATION TO SERIALIZABLE ;

So for read committed, for example, one can do:

ALTER DATABASE <db name> SET DEFAULT_TRANSACTION_ISOLATION TO 'read committed';

and you can confirm this with

SELECT current_setting('transaction_isolation')
like image 112
Ulad Kasach Avatar answered Oct 19 '25 02:10

Ulad Kasach



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!