The database is a bit complex one to understand for newcomers in Elgg. Everything in Elgg runs on a unified data model and it’s built on atomic data units called entities. All data in Elgg like site, user, blog posts, pages, photos, videos, etc. are managed as entities. So there is no need to create new database tables or fields to create new plugins with custom functionalities. This will helps the developers to make plugins faster and powerful.
With this blog i would like to throw light on the topic “Cleaning up Elgg database”
The importance of cleaning up Elgg database :
Most of the elgg sites mainly face some issues in database. So we need to clean up the database and solve these issues. It will help to improve the site speed, page crashing and will keep the databases clean from unnecessary data. The main issues are:
• Missing an entry in entity type table
• User without username or email
• Object / Group entity without owner guide
• Entity with deleted owner
• Orphaned annotations, metadata’s and metastring’s
Already Elgg provides a plugin named Garbage Collector for cleaning up the Elgg database tables.
First we are going to discuss how to setup the garbage collector plugin in Elgg and how it works.
1. Sign in to the Elgg site as Administrator mode
2. Go to the Plugins page on the Administration section.
3. Here we can find the Garbage Collector plugin and Enable it.
4. Once this plugin is enabled, we can see Settings link on the top of the plugin.
5. Go to the settings page and choose how many times you want the Garbage Collector clean your site databases (Once a weekly, once a monthly and once a year). Once a month is always recommended.
I have used this Garbage Collector plugin in some sites. It automatically deletes data from the database so I feel its bit risky because it would be difficult to tell what data is still needed and what is not. So I have created a new plugin named DB Freshener. I have designed a perfect UI to manage incomplete or corrupted data. It will help the administrator to view and decide what data is to be deleted. In this plugin, admin can check the site database using the button Check Database. When clicked on the Check Database button, it will display the incomplete or corrupted data. It will mainly manage the below details.
• Users with no Username / Email ID
• Incomplete Entities
• Orphaned Entities
• Orphaned Metadatas
• Orphaned Annotations
• Orphaned Metastrings
I have also added the option to Optimize Database Tables. Administrator can easy to optimize their site database tables using the Optimize Tables button.
Advantages of DB Freshener:
- Optimizes the website speed.
- Prevents Page crashing.
- Keeps the databases clean from unnecessary data.
I will come up with the Enterprise version of DB Freshner plugin soon and you can find it showcased in Cubet Product List:
Hope this effort will help you in finding an effective method to clean up the Elgg database.
Happy coding !