summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2013-05-09 15:42:14 +0200
committerAymeric Augustin <aymeric.augustin@m4x.org>2013-05-09 15:42:14 +0200
commit3d595c3bc38cf939503b69ce7a2802d5663f85b9 (patch)
treec5dc588cda41a1d7e23743fd537ba74e5f151b3e /docs/ref
parentf25fc5b2209b9c53cc0a71880ab049816f3a66a1 (diff)
Fixed #20215 -- Disabled persistent connections by default.
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/databases.txt33
-rw-r--r--docs/ref/settings.txt2
2 files changed, 22 insertions, 13 deletions
diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt
index 2ef048216f..7555acaaba 100644
--- a/docs/ref/databases.txt
+++ b/docs/ref/databases.txt
@@ -22,14 +22,14 @@ Persistent connections
.. versionadded:: 1.6
Persistent connections avoid the overhead of re-establishing a connection to
-the database in each request. By default, connections are kept open for up 10
-minutes — if not specified, :setting:`CONN_MAX_AGE` defaults to 600 seconds.
+the database in each request. They're controlled by the
+:setting:`CONN_MAX_AGE` parameter which defines the maximum lifetime of a
+connection. It can be set independently for each database.
-Django 1.5 and earlier didn't have persistent connections. To restore the
-legacy behavior of closing the connection at the end of every request, set
-:setting:`CONN_MAX_AGE` to ``0``.
-
-For unlimited persistent connections, set :setting:`CONN_MAX_AGE` to ``None``.
+The default value is ``0``, preserving the historical behavior of closing the
+database connection at the end of each request. To enable persistent
+connections, set :setting:`CONN_MAX_AGE` to a positive number of seconds. For
+unlimited persistent connections, set it to ``None``.
Connection management
~~~~~~~~~~~~~~~~~~~~~
@@ -64,13 +64,22 @@ least as many simultaneous connections as you have worker threads.
Sometimes a database won't be accessed by the majority of your views, for
example because it's the database of an external system, or thanks to caching.
-In such cases, you should set :setting:`CONN_MAX_AGE` to a lower value, or
-even ``0``, because it doesn't make sense to maintain a connection that's
-unlikely to be reused. This will help keep the number of simultaneous
-connections to this database small.
+In such cases, you should set :setting:`CONN_MAX_AGE` to a low value or even
+``0``, because it doesn't make sense to maintain a connection that's unlikely
+to be reused. This will help keep the number of simultaneous connections to
+this database small.
The development server creates a new thread for each request it handles,
-negating the effect of persistent connections.
+negating the effect of persistent connections. Don't enable them during
+development.
+
+When Django establishes a connection to the database, it sets up appropriate
+parameters, depending on the backend being used. If you enable persistent
+connections, this setup is no longer repeated every request. If you modify
+parameters such as the connection's isolation level or time zone, you should
+either restore Django's defaults at the end of each request, force an
+appropriate value at the beginning of each request, or disable persistent
+connections.
.. _postgresql-notes:
diff --git a/docs/ref/settings.txt b/docs/ref/settings.txt
index f2d418d4d9..04b42aeeb2 100644
--- a/docs/ref/settings.txt
+++ b/docs/ref/settings.txt
@@ -509,7 +509,7 @@ CONN_MAX_AGE
.. versionadded:: 1.6
-Default: ``600``
+Default: ``0``
The lifetime of a database connection, in seconds. Use ``0`` to close database
connections at the end of each request — Django's historical behavior — and