grade history cleanup

grade history cleanup

by A Guy -
Number of replies: 7

Ourgrade_grades, grade_grades_history, and grade_items_history tables are huge


In site administration->server->cleanup, I set grade history lifetime to 180 days/6 months whereas it had been set to no limit.


I ran cron several times.


Nothing happened to the size of the tables. I ran analyze/optimize/repair on our MySQL and nothing happened to the size of the tables.


I searched the code base for the table names and gradehistorylifetimeand didn't find any useful delete SQL commands/functions. So do I have to manually delete entries in the grade_grades_history and grade_items_history tables?

How does this work?


I also went to site administration->plugins->logging and changed standard log history to 6 months thinking that would help here. It didn't.


Again the tables are the same size.


Average of ratings: -
In reply to A Guy

Re: grade history cleanup

by A Guy -

No suggestions on how this works?

In reply to A Guy

Re: grade history cleanup

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Before I retired, when I needed to get rid of grade history and stuff, I did it by using the course Reset in the course administration block. Proceed cautiously, read carefully, and be careful you do not "reset" something you actually want to keep.

In reply to AL Rachels

Re: grade history cleanup

by A Guy -

we need something more global. we want to keep the last 6 months of every course. it would be ideal to keep all the history but per my post the tables are impossible to manage so we compromised and will settle for the last 6 months. setting that setting does not purge the older data from those tables. I need a SQL statement. I thought maybe delete from x where timemodified < unixtime([6 months ago date']) but I cannot find any code in moodle that speaks to this . . . if it is OK.

In reply to A Guy

Re: grade history cleanup

by Ken Task -
Picture of Particularly helpful Moodlers

Just how long are your courses?   1 (or 2 or 3) full year(s)?  Do these courses have an ending?   How 'large' are they ... that doesn't mean number of files, but users and processing ... quiz?  

And does anyone really look at the data contained therein that's over a year old?   When was the last time somone asked for that data?

Granted one might be under a records retention policy ... 5 years?

Nope ... no moodle tool ... think you'll have to rely on exporting directly from DB to a saved table.

The query would be on the epoch time stamp field and get 'less than' records.

'spirit of sharing', Ken

In reply to Ken Task

Re: grade history cleanup

by A Guy -

If there is no moodle tool then what is on that admin page (In site administration->server->cleanup->grade history lifetime )? What does it do? It doesn't appear to do anything.

In reply to A Guy

Re: grade history cleanup

by Ken Task -
Picture of Particularly helpful Moodlers

Well, then ... how often are you running cron job?

Is the cron job executing successfully?   Many have a 'quiet' parameter to the cron command ... goes to null.   Run it via web a few times and see if there's any section shown about clean up.

There are also 'task' ... have you disabled any of those that might be related?

Since table is large, have you checked DB server errors?

'spirit of sharing', Ken


In reply to Ken Task

Re: grade history cleanup

by A Guy -

Thanks for helping out, Ken. Like I said above I ran the cron many times. I don't see anything in the code that says that that even works. No one can help out. Sounds like it is a bug.