Code

Opened 4 years ago

Closed 3 years ago

#14231 closed (fixed)

Missing index on expire_date in Session model

Reported by: joeri 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: UI/UX:

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 4 years ago.

Download all attachments as: .zip

Change History (4)

Changed 4 years ago by joeri

comment:1 Changed 4 years ago by SmileyChris

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Ready 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 Changed 3 years ago by SmileyChris

  • Needs documentation set
  • Triage Stage changed from Ready for checkin to Accepted
  • Version 1.2 deleted

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 Changed 3 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

(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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.