The WordPress database stores a large amount of data over time, such as posts, comments, user data, and old versions of posts. As the volume of data increases, the speed of the website may decrease, which can negatively impact user experience and SEO.
Optimising the WordPress database, that is, removing unnecessary data and optimising tables, is an effective method for improving website performance. This process helps to reduce loading times and increase the speed of WordPress. Below, we explain the reasons for the importance of this optimisation and provide some tips.
Why is optimising the WordPress database important?
Optimising the WordPress database improves the speed and efficiency of the website. By removing unnecessary data, database errors are reduced and processing is accelerated.
This improvement in performance increases user satisfaction and can positively impact SEO, as Google and other search engines prefer faster websites. Furthermore, database optimization reduces server load and prevents excessive use of hosting resources.
The impact of database performance on website speed
Step-by-step guide to optimising the WordPress database
Step 1 – Create a backup of the database
Before any changes, a backup of the database should first be created. A backup ensures that the data can be restored in the event of an error or accidental deletion. For this, plugins like UpdraftPlus can be used, or a backup can be created via phpMyAdmin in the hosting control panel.
Step 2 – Cleaning up data through the dashboard
Go to the WordPress dashboard and remove unnecessary data such as spam and unapproved comments, old post revisions, auto-drafts, and redundant cache files from plugins. Plugins like WP-Optimize can automate this process.
Step 3 – Find and delete unused tables
Some plugins leave tables in the database after they are uninstalled that are no longer needed. You can access your database via phpMyAdmin or plugins like Advanced Database Cleaner to identify and delete unused tables.
Step 4 – Optimise existing tables
After removing unnecessary data, the existing tables should be optimised. This can be done using phpMyAdmin. Select the desired tables and click on 'Optimize Table'. This removes unused space and improves the efficiency of the database.
Step 5 – Use of Optimisation Plugins
For regular optimisation, it is advisable to use plugins such as WP-Optimize or Advanced Database Cleaner. These plugins automatically clean and optimise the tables, so no manual intervention is required.
More methods for optimising the database
- Use of caching plugins: Plugins like WP Rocket and W3 Total Cache store data as cache to reduce database queries.
- Optimised SQL queries: With advanced SQL knowledge, unnecessary data can be deleted directly from the database.
- Advanced hosting settings: Some hosting providers offer special resources for the database to improve its performance.
Additional measures for optimising the WordPress database
Removing orphaned data
Data that remains after deleting plugins, users, or posts should be cleaned up.
Removing transients
Temporary data that WordPress stores should be regularly deleted.
Disabling pingbacks and trackbacks
In the discussion settings, these features can be disabled and old data deleted.
Remove old shortcodes
Remnants of deleted plugins should be removed.
Delete unnecessary tags
Tags that are no longer used can burden the database.
Delete spam comments
In the file wp-config.php can the number of stored versions be limited:
define('WP_POST_REVISIONS', 3);
Uninstall unused plugins and themes
Unneeded plugins and themes should be deleted to relieve the database.
Two additional methods mostly used by professionals
Limiting database queries in themes and plugins
One of the reasons for the slowdown of the database is the high number of queries sent to the database by themes or plugins. For example, some plugins may repeatedly fetch dynamic information from the database, which increases the load on the database and thus reduces the speed of the website.
Here you can use methods such as caching queries, removing or optimising unnecessary queries in the code of themes and plugins. Additionally, you can identify and optimise additional requests with performance monitoring tools like Query Monitor.
Selection of suitable tables for data storage
Some plugins add additional data directly into the standard tables of WordPress, particularly in the wp_options table, which can lead to clutter and a slower database over time. To solve this problem, it is better to use plugins that store extensive and additional data in their own specific tables. This way, the accumulation of data in the standard tables can be avoided, keeping the database clean and fast.
Summary
In this article, we have comprehensively described how you can optimise the WordPress database – from basic steps like backing up to specific plugins and settings. By regularly carrying out these measures and removing unnecessary data, you can significantly improve the performance and stability of your WordPress website.