Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I truncate sessions and watchdog table in Drupal?

I have 16 million rows in these 2 tables in Drupal.My sites are slow and these 2 tables top the slow query log. Can I safely truncate them?

Also, issuing a truncate command, hangs the system. Is there a way I can delete rows in batches?

like image 579
Loveleen Kaur Avatar asked Oct 22 '10 04:10

Loveleen Kaur


2 Answers

Watchdog yes, Session has a timestamp that you should probably use to make sure any currently connected users don't lose their session. If you don't mind a little downtime, it might be worth it to turn the maintenance option on and then truncate both tables at a traffic-low/ appropriate time.

like image 196
Al W Avatar answered Oct 24 '22 13:10

Al W


You have an answer to your immediate problem, but dblog should be pruned automatically by cron. The number of rows to keep is a setting, admin/settings/logging/dblog

dblog can also be cleared and pruned to an extent with drush.

like image 37
mpdonadio Avatar answered Oct 24 '22 14:10

mpdonadio