Monday, July 21, 2014

I found this table today in my moodle install comprising about 75% of my total DB size

I had been watching my db size creaping up over the past few weeks and thought, "what the $#$% is going on?"  Why is my DB growing so much?

I spent a lot of time looking at the logs on certain dates to see if it was something a user(s) was doing, or perhaps a vendor had loaded a new course, a really big one.....

I have automated DB backups that occur 3 times a week and I was watching this and seeing how the DB was increasing, alot, say over 100 MB literaly overnight.  This has been causing me some stress, especially since I have a pending upgrade to do and the larger the DB, the more problematic the upgrade (that is me extrapolating, not the moodle documentation).

The GREAT thing that I discovered today using this handy snippet

SELECT table_name , table_rows, data_length,
  round(((data_length+index_length)/1024/1024),2)  AS "Size in MB"
  FROM information_schema.tables
         
   where table_schema = "db name"
         
   ORDER BY data_length desc
"

Look at the results:





















654 MB of data in 938 rows?  What the $#%$$##$#$@@@$@$.  Sorry, I already said that.

Well, I found this little forum with a bit of conversation and have decided to kill the content in the table.  I will leave the table, but kill the rows.  Then, I will watch to see if it grows like a cancer cell again.  Hopefully not.  In the mean time, my DB is much smaller.

1 comment:

  1. I actually dropped the table and rebuilt it, using a script, rather than trying to edit the rows of that very large table. Using MySQL workbench, I created a *create the table script, dropped the table and ran the script.

    ReplyDelete