mdl_messages table
Field name Type Allow nulls? Key Default value Extras
id bigint(10) No Primary NULL auto_increment
useridfrom bigint(10) No Indexed NULL
conversationid bigint(10) No Indexed NULL
subject longtext Yes None NULL
fullmessage longtext Yes None NULL
fullmessageformat tinyint(1) No None 0
fullmessagehtml longtext Yes None NULL
smallmessage longtext Yes None NULL
timecreated bigint(10) No None NULL
customdata longtext Yes None NULL
fullmessagetrust tinyint(2) No None 0
If one deletes all message from a user by useridfrom, then aren't there now some
orphaned 'conversations' left in the table?
For the sanity of OP's DB, think it best to change settings at URL:
/admin/settings.php?section=messages
Clips of a couple of options located in link above:
Delete read notifications messagingdeletereadnotificationsdelay
default is 1 week
Delete all notifications messagingdeleteallnotificationsdelay
Read and unread notifications can be deleted to save space. How long after a notification is created can it be deleted?
Default is 1 months
Least amount of time is 1 day, other higher options are 3 months, 6 months, never.
There doesn't appear to be any scheduled task for messages cepr for Messages digest mailings
If set to 1 day, let cron job/whatever do it's thing for 2 days - giving it plenty of time to 'clean up', then check to see the situation of messages has improved.
If 'cleaned up', one could reset to 1 months again until the next time it gets to be too much then reset to 1 day again.
One could be rid of the issue by truncating mdl_messages table ... starting over again.
But thought OP can made statements to the effect messages were crucial to his moodle.
My 2 cents.