Opened 14 years ago

Closed 14 years ago

#14231 closed (fixed)

Missing index on expire_date in Session model

Reported by: Joeri Bekker Owned by: nobody
Component: contrib.sessions Version:
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

We recently found that the Django session table, in a particular project setup, was not regularly cleaned. When we tried to do this manually (excluding recent entries), the select/delete action took like forever.

This was because there is no index defined on the "expire_date" field in the Session model and thus any action with a WHERE-clause on that field takes much longer than needed. Ruby had the same problem (long ago) and added an index on the expire_date field and I think Django should just do the same.

Kudos to Frodo from Medid for noticing this.

Attachments (1)

django_session_index.patch (609 bytes ) - added by Joeri Bekker 14 years ago.

Download all attachments as: .zip

Change History (4)

by Joeri Bekker, 14 years ago

Attachment: django_session_index.patch added

comment:1 by Chris Beaven, 14 years ago

Triage Stage: UnreviewedReady for checkin

I'm going to push this straight to ready for checkin. It's valid and I've verified with Malcolm.

A new documentation file, kept out of trunk, needs to be created to track these types of things (but kept out of the sphinx build). I've added a new ticket #14258 to track that.

comment:2 by Chris Beaven, 14 years ago

Needs documentation: set
Triage Stage: Ready for checkinAccepted
Version: 1.2

I don't know why I was saying that this should be kept out of trunk. It makes sense that it'd go in the standard release notes.

comment:3 by Russell Keith-Magee, 14 years ago

Resolution: fixed
Status: newclosed

(In [14378]) 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.

Note: See TracTickets for help on using tickets.
Back to Top