Moodle recently cleaned-up the database tables for Messaging…
This is one for the techies, and those looking towards the future.
For many years Moodle had two tables for Messages – mdl_message and mdl_message_read.
From Moodle 3.5 these are combined into a single table with a “read” column.
A lot of testing and profiling was required by developers to ensure that the check for unread messages does not unduly burden the server if the message table is large.
There were actually three related Tracker items that went into this seemingly small change:
- MDL-61254 – Merge messaging database tables
- MDL-36941 – Create new tables for messaging
- MDL-61255 – Ad-hoc task to upgrade messages to merged table
Interestingly, these changes make zero difference to users right now.
There is some history behind this though…
…the only reason for the introduction of this 2 table system was that the person who did the GSOC project that created the messaging system thought it was necessary to be able to quickly check for unread messages when in fact an indexed column on a single table does just as well.
If you want to see how much work went into this change take a look at https://tracker.moodle.org/browse/MDL-36941
The cleaning up of these tables and re-thinking of how they work, will pay dividends in the future with more flexible options.