Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

My GDN_Session table is over 80MB. Can I empty it

aeryaery Gtricks Forum in 2.2 :) ✭✭✭

I think it will improve some performance

There was an error rendering this rich post.

Comments

  • Yep, I think you can. You have backups, right?

    There was an error rendering this rich post.

  • aeryaery Gtricks Forum in 2.2 :) ✭✭✭

    yeah

    There was an error rendering this rich post.

  • @aery i have created a cron job for that, deleting every 3 days to make self-hosted site lighter :D

  • @fr3333333x said:
    i have created a cron job for that

    Share! Share! :-) on the Wiki or here :-)

    There was an error rendering this rich post.

  • if you delete sessions, more elegant to delete older than some time.

    grep is your friend.

  • businessdadbusinessdad Stealth contributor MVP

    @x00 said:
    if you delete sessions, more elegant to delete older than some time.

    Sorry, I'm not sure I understood this correctly. Could you please clarify? Thanks. :)

  • don't delete all the session just older ones, also known as pruning

    grep is your friend.

  • businessdadbusinessdad Stealth contributor MVP

    Ah, now I got it. That's what I do already, which is the reason why I didn't get it straight away (I consider it the "default" way of deleting old stuff). Thanks for the clarification. :)

  • fr3em1ndfr3em1nd ✭✭
    edited February 2013

    @UnderDog i'll share but somehow this is just a silly program i made for cron..

    the code is below, you can add it to your CPANEL cronjob mine i have set it up every 1 hour.

    I wish someone could create a plugin for this it would be helpful :D


    <?php $hostname_cnCleaner = "localhost"; $database_cnCleaner = "YOUR_DATABASE_NAME"; $username_cnCleaner = "YOUR_DATBASE_USERNAME"; $password_cnCleaner = "YOUR_DATBASE_PASSWORD"; $cnCleaner = mysql_pconnect($hostname_cnCleaner, $username_cnCleaner, $password_cnCleaner) or trigger_error(mysql_error(),E_USER_ERROR); date_default_timezone_set('Asia/Manila'); ?>


    <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_cnCleaner, $cnCleaner); $query_rsClean = "DELETE FROM `YOUR_DATABASE_NAME`.`GDN_Activity` WHERE `YOUR_DATABASE_NAME`.`GDN_Activity`.`DateInserted` < (NOW() - INTERVAL 2440 MINUTE)"; $rsClean = mysql_query($query_rsClean, $cnCleaner) or die(mysql_error()); echo "ACTIVITY: ".date('h:i:s') . " DELETED: ".mysql_affected_rows(); ?>

    you can setup the INTERVAL 2440 MINUTE to any time that you want the history to be deleted from to current date.

  • businessdadbusinessdad Stealth contributor MVP

    @fr3333333x said:
    UnderDog i'll share but somehow this is just a silly program i made for cron..

    the code is below, you can add it to your CPANEL cronjob mine i have set it up every 1 hour.

    I wish someone could create a plugin for this it would be helpful :D

    Creating a plugin should be quite easy. My Cron plugin was created exactly for this kind of things. All you would have to do would be creating a fairly simple plugin, which does just two things:

    • Implement a handler for Cron plugin's registration event.
    • On Execute, run the above code, by using Vanilla DB Objects, rather than a direct MySQL query (I'd like to take the opportunity to remind that mysql_* functions are deprecated and that PDO should be used instead).
    • Create a crontab task that calls the cron URL created by the plugin.
  • @businessdad thanks for your that advice, i'll take that seriously. .. somehow right now i'm still focusing on themes and templates. I really would like to dig deeper in to coding and making plugins :)

    this is just a dirty workaround i made coz of frustration of server overloads xD

  • phreakphreak Vanilla*APP (White Label) & Vanilla*Skins Shop MVP

    Hi alle,

    I'd like to hang in here another table that could be cleaned from time to time i think. GDN_Draft can also grow a little, even though some people left the forum or just don't manage old drafts anymore.

    Does anyone know if this table ha a correlation to another table? If not, and drafts are just driven through this table you could possibly clean those drafts that were last updated in 2010 or 2011 for example.

    Greetz, i just went again through my board which recently rund a 100MB database, cleaning a little brought me down to 75MB.

    Backup, backup, backup before!

    • VanillaAPP | iOS & Android App for Vanilla - White label app for Vanilla Forums OS
    • VanillaSkins | Plugins, Themes, Graphics and Custom Development for Vanilla
Sign In or Register to comment.