views:

61

answers:

3

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?

+3  A: 

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.

Al W
@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.
Loveleen Kaur
ok got it..limiting the rows when I delete them..thanks for the help.!
Loveleen Kaur
+1  A: 

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.

MPD
A: 

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

Jose Daniel

related questions