Author: russellm
Date: 2010-10-28 06:56:37 -0500 (Thu, 28 Oct 2010)
New Revision: 14378

Modified:
   django/trunk/django/contrib/sessions/models.py
   django/trunk/docs/releases/1.3.txt
Log:
Fixed #14231 -- Added an index to the expire_date column on the Session model. 
Thanks to joeri for the report, via Frodo from Medid.

This won't affect any existing session tables; see the release notes for 
migration instructions.

Modified: django/trunk/django/contrib/sessions/models.py
===================================================================
--- django/trunk/django/contrib/sessions/models.py      2010-10-28 11:47:15 UTC 
(rev 14377)
+++ django/trunk/django/contrib/sessions/models.py      2010-10-28 11:56:37 UTC 
(rev 14378)
@@ -45,7 +45,7 @@
     session_key = models.CharField(_('session key'), max_length=40,
                                    primary_key=True)
     session_data = models.TextField(_('session data'))
-    expire_date = models.DateTimeField(_('expire date'))
+    expire_date = models.DateTimeField(_('expire date'), db_index=True)
     objects = SessionManager()
 
     class Meta:

Modified: django/trunk/docs/releases/1.3.txt
===================================================================
--- django/trunk/docs/releases/1.3.txt  2010-10-28 11:47:15 UTC (rev 14377)
+++ django/trunk/docs/releases/1.3.txt  2010-10-28 11:56:37 UTC (rev 14378)
@@ -165,6 +165,24 @@
             model = Document
             widgets = {'document': forms.FileInput}
 
+New index on database session table
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Prior to Django 1.3, the database table used by the database backend
+for the :doc:`sessions </topics/http/sessions>` app had no index on
+the ``expire_date`` column. As a result, date-based queries on the
+session table -- such as the query that is needed to purge old
+sessions -- would be very slow if there were lots of sessions.
+
+If you have an existing project that is using the database session
+backend, you don't have to do anything to accommodate this change.
+However, you may get a significant performance boost if you manually
+add the new index to the session table. The SQL that will add the
+index can be found by running the :djadmin:`sqlindexes` admin
+command::
+
+    python manage.py sqlindexes sessions
+
 .. _deprecated-features-1.3:
 
 Features deprecated in 1.3

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to