I’m running django site with MySQL as DB back-end.
Finally i’ve got 3 millions rows in django_session table. Most of them are expired, thus i want to remove them.
But if i manually run delete from django_session where expire_date < "2011-04-18" whole site seems to be hanged – it cannot be accessed via browser.
Why such kind of blocking is possible? How to avoid it?
If your table is
MyISAM,DELETEoperations lock the table and it is not accessible by the concurrent queries.If there are many records to delete, the table is locked for too long.
Split your
DELETEstatement into several shorter batches.