From e0449316ebacaa550e9c529f8c9cb9a9b44e3765 Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Sat, 2 Mar 2013 15:00:28 +0100 Subject: Fixed #18130 -- Made the isolation level configurable on PostgreSQL. Thanks limscoder for the report and niwi for the draft patch. --- docs/ref/databases.txt | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'docs/ref') diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt index 34f60e99ac..4e435949a2 100644 --- a/docs/ref/databases.txt +++ b/docs/ref/databases.txt @@ -143,8 +143,11 @@ autocommit behavior is enabled by setting the ``autocommit`` key in the :setting:`OPTIONS` part of your database configuration in :setting:`DATABASES`:: - 'OPTIONS': { - 'autocommit': True, + DATABASES = { + # ... + 'OPTIONS': { + 'autocommit': True, + }, } In this configuration, Django still ensures that :ref:`delete() @@ -168,6 +171,34 @@ You should also audit your existing code for any instances of this behavior before enabling this feature. It's faster, but it provides less automatic protection for multi-call operations. +Isolation level +~~~~~~~~~~~~~~~ + +.. versionadded:: 1.6 + +Like PostgreSQL itself, Django defaults to the ``READ COMMITTED`` `isolation +level `_. If you need a higher isolation level +such as ``REPEATABLE READ`` or ``SERIALIZABLE``, set it in the +:setting:`OPTIONS` part of your database configuration in +:setting:`DATABASES`:: + + import psycopg2.extensions + + DATABASES = { + # ... + 'OPTIONS': { + 'isolation_level': psycopg2.extensions.ISOLATION_LEVEL_SERIALIZABLE, + }, + } + +.. note:: + + Under higher isolation levels, your application should be prepared to + handle exceptions raised on serialization failures. This option is + designed for advanced uses. + +.. _postgresql-isolation-levels: http://www.postgresql.org/docs/devel/static/transaction-iso.html + Indexes for ``varchar`` and ``text`` columns ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- cgit v1.3