6
votes

I was wondering what's the default isolation level when using Django with PostgreSQL database. Serializable Isolation? (https://www.postgresql.org/docs/9.1/static/transaction-iso.html#XACT-SERIALIZABLE)

There is a discussion about MySQL (Django transaction isolation level in mysql & postgresql) but despite its name is doesn't seem to discuss PostgreSQL

Thanks!

2

2 Answers

9
votes

From the docs:

Like PostgreSQL itself, Django defaults to the READ COMMITTED isolation level.

2
votes

Django can be configured using the database settings like this:

import psycopg2.extensions

DATABASES = {
    # ...
    'OPTIONS': {
        'isolation_level': psycopg2.extensions.ISOLATION_LEVEL_SERIALIZABLE,
    },
}

Documentation - https://docs.djangoproject.com/en/2.2/ref/databases/#isolation-level