MyBB Community Forums

Full Version: Can mybb_sessions be safely truncated?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am restoring from a backup (SQL script) that is approx. 15GB.

It is taking days and days, especially since mybb_sessions is very large (approx 14GB?).

Can this table just be truncated (all rows deleted) without loss of functionality as I am thinking it is just a 'temporary' non-critical data while forums are up?

Thanks.
Yes, it can. But there shouldn't be that much data. Make sure that your tasks are running successfully. Old sessions should be cleaned out daily.
(2013-02-13, 06:40 AM)Nathan Malcolm Wrote: [ -> ]Yes, it can. But there shouldn't be that much data. Make sure that your tasks are running successfully. Old sessions should be cleaned out daily.

I checked the daily prune/maintenance:

inc/tasks/dailycleanup.php: // Clear out sessions older than 24h
inc/tasks/dailycleanup.php: $db->delete_query("sessions", "uid='0' AND time < '{$cut}'");

It only deletes rows with uid=0, but most rows are uid<>0 so the daily cleanup would not reduce the size much?

What is this table used for if truncating does not reduce functionality?
(2013-02-13, 07:25 AM)bahadur Wrote: [ -> ]most rows are uid<>0 so the daily cleanup would not reduce the size much?
How many users do you have?
How active is your forum? The largest MyBB forum with 24 million posts has a database size of around 22 - 25 GB. Unless you have thousands upon thousands of active users (or perhaps if you've set the cut off time to something ridiculous like 999999999 minutes) there's certainly something wrong.

The table is used for user tracking (who's online, what page someone is viewing, etc...).
(2013-02-13, 07:35 AM)Nathan Malcolm Wrote: [ -> ]How active is your forum? The largest MyBB forum with 24 million posts has a database size of around 22 - 25 GB. Unless you have thousands upon thousands of active users (or perhaps if you've set the cut off time to something ridiculous like 999999999 minutes) there's certainly something wrong.

The table is used for user tracking (who's online, what page someone is viewing, etc...).

Approx 45K users but probably most are inactive (it is not my forum, but helping someone out so I do not know the settings offhand).

Is it correct to say that mybb_sessions has little use once the forums are down?

Hence I can safely truncate, restore the DB, then work on the proper settings to ensure it does not bloat again (probably deleting inactive users will do the trick also).