On 8/20/2010 9:44 PM, Russell Keith-Magee wrote:
> On Fri, Aug 20, 2010 at 11:51 PM, bfrederi <brfrederi...@gmail.com> wrote:
>> I just wanted to know if anyone had an opinion or whether running a
>> django-admin.py cleanup on 40 million session rows might slow down or
>> lock up the database. I would like to do this cleanup ASAP, but I was
>> concerned it might cause some issues.
> 
> It depends entirely on your database. If you're using MySQL with
> MyISAM tables, then almost certainly yes due to the table-level
> locking. Other databases may be affected for different reasons.
> 
> If you're trying to evaluate the risk, the cleanup command executes
> the following:
> 
> Session.objects.filter(expire_date__lt=datetime.datetime.now()).delete()
> 
> Which is the SQL equivalent of:
> 
> DELETE FROM django_session WHERE expire_date > '2010-01-01 1:23:45';
> 
> inside a the default transaction mode for your database. You'll have
> to consult your database documentation to establish whether that will
> pose a locking risk.
> 
> Yours,
> Russ Magee %-)
> 
Alternatively you could choose to delete these rows without using the
cleanup function. This would allow you to delete them in chunks small
enough to have much lower impact on the database.

regards
 Steve

-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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

Reply via email to