10

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?

4 Answers 4

13

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.

2
  • @AW , Can you tell me of a way that I can delete rows in batches. Truncating the tables entirely causes the system to hang and the tables to crash. Oct 22, 2010 at 5:37
  • ok got it..limiting the rows when I delete them..thanks for the help.! Oct 22, 2010 at 5:58
4

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.

2

I can recommend the Session expire module for Drupal: http://drupal.org/project/session_expire

This will clean up the sessions table for any PHP settings, and is called during cron making it run predictably in the background no matter your PHP garbage collection settings

1

Watchdog and cache tables yes, but if you truncate session may be some users will lose their sessions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.