Large size of table in the MySQL database


I have an Elgg site with about 2000 registered users, about 100 active users and about 500 visitors per day.

Many different content, mainly large texts and images.

I see that the size of the table elgg_users_sessions in my database is very large, more than 250MB. The entire database has about 400MB.

Is it normal?

If not, what could be the reason?

  • As far as I know the elgg_users_sessions table should normally get cleaned up automatically. It's controlled by some php variables. See

    The variables session.gc_probability and session.gc_divisor control the probability that a cleanup occurs. With the default values (session.gc_probability = 1 and session.gc_divisor = 1000) the cleanup would happen with a probability of session.gc_probability/session.gc_divisor = 0.1%.

    You might want to check the values of these php variables have on your server (php.ini). With phpinfo() you can check. Just save a script named phpinfo.php with the following content


    and save it in the root folder of your Elgg site. The call it in the browser with your_site.url/phpinfo.php (best remove it again after you are done). If session.gc_probability is 0 on your server, the cleanup would never happen. If you can't modify the php.ini on your server it might work to set the values in Elgg's .htaccess (just do it in the same way as the other php variables like memory_limit are set).

    It's probably safe to empty the elgg_users_sessions table (but not deleting the table just its content!). Never did that myself, so I would advice to backup the database before trying this. Also, this would result in all users getting logged out (they would have to log in again afterwards).

  • Thank you very much! Indeed, problem was in php.ini.

Performance and Scalability

Performance and Scalability

If you've got a need for speed, this group is for you.