Thursday, February 25, 2016

My moodle DB largest table to smallest

In terms of MB, of course.  I like to keep an eye on the size of the moodle db.  Its a very important piece of the moodle system.  Looking today with a lense of table size.  If my DB is 350 MB, which tables are comprising most of that data?  A good question to ask and investigate and maybe to use as a base for trimming down the size.

I have a SQL statement that does this saved as a snippet in MySQL Workbench, naturally.  Looks like this:
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 = "dbname"
    ORDER BY Size_in_MB desc
The results are interesting.  They show that most of the data in the moodle db comes from questions, files, the log file and more details around questions and grades.  It is no surprise considering the moodle i am looking at is the one that hosts our AccelerateU service, which provides credit bearing courses for NYS public high school students.

There are lots of 3rd party courses, from vendors that have lots of quizzes in them and lots of quiz questions and answers.  consequently, there is lots of grade data for the quiz questions.







































I will look at pruning a little from a couple of the tables using snippets like this.


No comments:

Post a Comment