Make expired session clearing on database backend scale better

https://code.djangoproject.com/ticket/23830