{"id":28122,"date":"2021-08-11T17:00:25","date_gmt":"2021-08-11T15:00:25","guid":{"rendered":"https:\/\/qodeinteractive.com\/magazine\/?p=28122"},"modified":"2022-01-11T12:01:19","modified_gmt":"2022-01-11T11:01:19","slug":"how-to-optimize-wordpress-database","status":"publish","type":"post","link":"https:\/\/qodeinteractive.com\/magazine\/how-to-optimize-wordpress-database\/","title":{"rendered":"How to Easily Optimize Your WordPress Database"},"content":{"rendered":"<div class=\"wpb-content-wrapper\"><p>[vc_row][vc_column][vc_column_text]The database stores all of a website\u2019s information. This includes the content of all pages and posts, information on themes and plugins, and various other settings, options, and relational data. Any site that has been around for a while has likely accumulated database bloat along the way.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Besides taking unnecessary storage space, database bloat can hurt a website\u2019s performance and any processes that are run in the backend. As such, optimizing your WordPress database by removing any unnecessary data can help your website run more efficiently. In this article, we will discuss all the ways your database can accumulate unnecessary data and how to optimize it accordingly. If you\u2019d like to skip to any specific part of the article, just click on one of the links below:[\/vc_column_text][vc_empty_space height=&#8221;22px&#8221;]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\"><a href=\"#why-you-should-optimize-your-wordpress-database\">Why you should optimize your WordPress database<\/a><\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;5px&#8221;]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\"><a href=\"#optimize-wordpress-database-with-a-plugin\">How to optimize your WordPress database with a plugin<\/a><\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;5px&#8221;]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\"><a href=\"#optimize-wordpress-database-manually\">How to optimize your WordPress database manually<\/a><\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;68px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h2 class=\"qodef-h4\"><a id=\"why-you-should-optimize-your-wordpress-database\"><\/a>Why you should optimize your WordPress database<\/h2>\n<p>[\/vc_column_text][vc_column_text]There are a lot of benefits to optimizing your WordPress database. The most obvious ones include having your server run more efficiently and improving your website\u2019s performance. As a result, your website\u2019s visitors will have a better experience while browsing through your content, which can lead to increased engagement and higher conversions.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Besides that, there are other benefits to consider. An optimized database is a must for users who have limited storage space in their hosting plans. And, if you plan on migrating your website to a different server, you should optimize your database as some migration plugins put a storage limit on the amount of data you can migrate.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Now we\u2019ll take a quick look at all the ways database bloat gathers on your website to help you understand what you need to remove. This includes unnecessary <a href=\"https:\/\/qodeinteractive.com\/magazine\/how-to-undo-changes-in-wordpress\/\">post revisions<\/a>, auto-draft versions of posts and trashed posts you don\u2019t need, spam, trashed and unapproved comments, expired transients, pingbacks, and trackbacks, leftover or unoptimized database tables, and leftover data. We\u2019ll give a brief overview of what each of those is below.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Post revisions were introduced way back in the WordPress 2.6 update. They represent previous versions of your updated posts and drafts that you can revert to. However, since all this data is stored inside your database, it can quickly pile up. As such, restricting the number of revisions that are kept within the database or completely removing them can help reduce the size of your database.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Items in the trash can also make a large portion of the database bloat. Unless restored, those items will remain in the trash for 30 days before they are permanently removed. As such, if you are running an active website, your trash could be full of items, so much so that even permanently removing them in bulk could take a lot of time and effort.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]If comments are enabled on your website, you almost certainly experienced issues <a href=\"https:\/\/qodeinteractive.com\/magazine\/how-to-moderate-wordpress-comments\/\">combating spam<\/a> either from real users or, most often, bots. Luckily, WordPress allows you to combat this issue to some degree. This is done by unapproving a comment, trashing it, or by marking it as spam, to remove it from being publicly visible on the website. However, those comments will still be stored in the database, adding to the existing database bloat. You can choose to permanently remove them, which will somewhat reduce that database bloat.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Transients allow WordPress developers to store data with an expiration date, which would otherwise slow your website if loaded on every page load. In that sense, they serve a similar purpose to the browser cache. However, after transients expire, you should remove them to expunge that unnecessary data from your database and to see the real result on your website, if you are testing a functionality, for example.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<a href=\"https:\/\/qodeinteractive.com\/magazine\/wordpress-pingbacks-and-trackbacks\/\">Pingbacks and trackbacks<\/a> are a WordPress feature that has, for the most part, become less popular nowadays. If you\u2019re using them, deleting the ones in your database is a way to optimize your WordPress database and remove the bloat. However, if you don\u2019t know what pingbacks and trackbacks are or want to learn more about them, check out the article we linked above. Once you\u2019re aware of all the pros and cons, you can decide whether to use them in the first place or not.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Some plugins may add additional tables to your database and fill it with relevant data. However, deactivating and deleting those plugins won\u2019t necessarily delete those additional tables as well. This can end up dragging down your website and making it slower than it should be. As such, it is important to optimize your database from time to time by removing those unnecessary, leftover tables. Since MySQL relies on relations between the data, simply removing something from one table could result in orphaned data. This is data that was related to whatever you deleted; such as getting stuck with the database tables of a plugin you removed. You will need to delete any orphaned data to reduce the size of your database and optimize its performance. This includes the orphaned post, comment, and relationship metadata.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Furthermore, you can reorganize the existing data, so that it takes up less storage space and can be accessed more efficiently. This is done by using the <em>Optimize table<\/em> option within phpMyAdmin or an equivalent plugin option that relies on it.[\/vc_column_text][vc_empty_space height=&#8221;80px&#8221;][vc_widget_sidebar sidebar_id=&#8221;new-top-picks-banner&#8221;][vc_empty_space height=&#8221;80px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h2 class=\"qodef-h4\">How to optimize your WordPress database<\/h2>\n<p>[\/vc_column_text][vc_column_text]With a clearer picture of all the benefits of optimizing a WordPress database, we can explore how this is actually done. As with most of our guides, we\u2019ll describe two methods for you to choose from\u2014using plugins or using the manual approach. Before we start, tinkering with the database can potentially harm your website, so we highly recommend <a href=\"https:\/\/qodeinteractive.com\/magazine\/how-to-backup-wordpress-database\/\">making a database backup<\/a> beforehand. Making regular database and website backups is good practice in general. With that being said, let\u2019s begin.[\/vc_column_text][vc_empty_space height=&#8221;72px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h3 class=\"qodef-h5\"><a id=\"optimize-wordpress-database-with-a-plugin\"><\/a>Using a WordPress optimization plugin<\/h3>\n<p>[\/vc_column_text][vc_column_text]Given the abundance of WordPress plugins, it is quite easy to find one suitable for almost any purpose. When it comes to optimizing your WordPress database, you can look for plugins built primarily for database optimization or those designed for improving the performance of your website as a whole. We opted to look in the latter category and picked WP-Optimize as the plugin that we\u2019ll use in this article.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]The <a href=\"https:\/\/wordpress.org\/plugins\/wp-optimize\/\" target=\"_blank\" rel=\"noopener\">WP-Optimize<\/a> plugin is a very versatile performance-optimization plugin. It specializes in three areas: cleaning and optimizing the database, optimizing images, and page caching. It is a freemium plugin, with the premium version unlocking further features like multisite support, sophisticated scheduling, WP-CLI support, lazy loading, and premium support. As for the database optimization options, it allows you to remove all the unnecessary data and unused tables, as well as schedule optimization weekly while retaining data from a set period. The plugin\u2019s interface is very intuitive and it helps you track the storage statistics of your database and the savings you can achieve.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]After <a href=\"https:\/\/qodeinteractive.com\/magazine\/how-to-install-a-wordpress-plugin\/\">installing the plugin<\/a>, <strong>navigate to WP-Optimize &gt; Database<\/strong> to examine all the database-related settings. In the main section of your screen, <strong>you will notice three tabs: <em>Optimizations<\/em>, <em>Tables<\/em>, and <em>Settings<\/em><\/strong>, with the <em>Optimizations<\/em> tab open by default. Although we\u2019ll cover all three tabs, we\u2019ll focus on <em>Optimizations<\/em> in particular.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]In the <em>Optimizations<\/em> tab, you will see all the possible optimization actions you can perform over your tables and data. Some of those actions will be preselected, while others will have a warning sign next to them. The warning sign will be accompanied by the following warning message at the bottom of your screen:[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<em>\u201cItems marked with this icon perform more intensive database operations. In very rare cases, if your database server happened to crash or be forcibly powered down at the same time as an optimization operation was running, data might be corrupted. You may wish to run a backup before optimizing.\u201d<\/em>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Therefore, if you haven\u2019t done so already, you should make a database backup before going any further.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"545\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Plugin-Warning.jpg\" class=\"attachment-full size-full\" alt=\"Plugin Warning\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Plugin-Warning.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Plugin-Warning-300x169.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Plugin-Warning-768x432.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Plugin-Warning-620x349.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Each of the optimization actions listed by the plugin will have an explanation accompanying it, showing how relevant they are to your database (e.g. how many trashed posts you have for deletion). Then, <strong>you can select the actions you want to perform by ticking the checkbox next to each option<\/strong>. To finish, <strong>press the <em>Run all selected optimizations<\/em> button<\/strong> near the top of the <em>Optimizations<\/em> tab. Alternatively, you can choose to perform one optimization at a time, by pressing the <em>Run optimization<\/em> button located in each row.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"705\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/WP-Optimize-Database-Optimizations.jpg\" class=\"attachment-full size-full\" alt=\"WP Optimize Database Optimizations\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/WP-Optimize-Database-Optimizations.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/WP-Optimize-Database-Optimizations-300x218.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/WP-Optimize-Database-Optimizations-768x559.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/WP-Optimize-Database-Optimizations-620x451.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]With that, you will perform the majority of the available optimization options. However, there are two tabs remaining for us to explore.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]In the <em>Tables<\/em> tab, you will see an overview of all your tables. The tables that were added by a plugin will show which plugin they belong to. The two columns that you should pay special attention to are the <em>Overhead<\/em> and the <em>Actions<\/em>. The <em>Overhead<\/em> represents the unnecessary data inside a table, which we removed by optimizing the database tables. While the <em>Actions<\/em> allow you to delete a table. This option is available only for tables that correspond to plugins that are either deactivated or even uninstalled on your website. For deactivated plugins, the notice next to the plugin table will state <em>inactive<\/em>, while for uninstalled plugins it will say <em>not<\/em> <em>installed<\/em>.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"700\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/WP-Optimize-Tables-Inactive.jpg\" class=\"attachment-full size-full\" alt=\"WP Optimize Tables Inactive\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/WP-Optimize-Tables-Inactive.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/WP-Optimize-Tables-Inactive-300x217.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/WP-Optimize-Tables-Inactive-768x555.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/WP-Optimize-Tables-Inactive-620x448.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]You should review all the plugins that are currently deactivated on your website and remove the ones that you don\u2019t plan on using again. This will also go towards improving the performance of your website. Once you\u2019ve done that, the status of the associated table will change, as you can see in the screenshot above. <strong>To fully uninstall a plugin, you will need to remove the leftover table(s) by pressing the <em>Remove<\/em> button located within the same row.<\/strong> After pressing the button, you will be prompted with a popup window asking you to confirm your selection. <strong>Read the warnings carefully. If you are sure you want to remove that table, tick the <em>I confirm<\/em> checkbox and press the <em>Remove the table<\/em> button, which will appear below.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"518\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Plugin-Remove-The-Table.jpg\" class=\"attachment-full size-full\" alt=\"Plugin Remove The Table\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Plugin-Remove-The-Table.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Plugin-Remove-The-Table-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Plugin-Remove-The-Table-768x411.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Plugin-Remove-The-Table-620x331.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]The selected table will be removed shortly after.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]As for the <em>Settings<\/em> tab, this is where you can enable scheduled clean-ups and manage what data is being retained based on the date it was created. Select what actions a scheduled clean-up will perform and its timeframe (the default setting is weekly). As for the actions, the choice includes most of the actions offered in the <em>Optimizations<\/em> tab. <strong>After you select all the settings you want, you can click on the <em>Save settings<\/em> button below to save them.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"700\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/WP-Optimize-Settings.jpg\" class=\"attachment-full size-full\" alt=\"WP Optimize Settings\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/WP-Optimize-Settings.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/WP-Optimize-Settings-300x217.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/WP-Optimize-Settings-768x555.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/WP-Optimize-Settings-620x448.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;82px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h3 class=\"qodef-h5\"><a id=\"optimize-wordpress-database-manually\"><\/a>Manually optimizing your database<\/h3>\n<p>[\/vc_column_text][vc_column_text]Besides using a suitable WordPress plugin, there is another way to properly optimize your WordPress database. It involves using database-altering queries and limiting some built-in WordPress features by editing the wp-config.php file. In the process, you will be able to achieve most of the functionalities provided by the plugin we mentioned above. However, this optimization method should be done carefully and it is most suitable for intermediate-to-advanced WordPress users. As a safety precaution, we again recommend making a database backup before proceeding to do any work on the database.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;22px&#8221;]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\"><strong>Requirements for manually optimizing the database<\/strong><\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Before we jump into the methods for optimizing the database, we wanted to make an overview of the things you need to know to perform them properly. We dedicated this section to the overview as keeping it separate will make it easier for readers to come back to it later. As an added benefit, it will let us avoid any repetitiveness later in the article.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<strong>Editing the wp-config.php file<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]The wp-config.php file is one of the core files within a WordPress installation. It is used to connect your website with its database and it allows the user to enable some important server settings for their website. By editing this file, you can enable some database-optimizing features.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]To open the wp-config.php file, you would need to first <strong>connect to your server<\/strong> using your FTP credentials and to <strong>navigate to the root WordPress directory<\/strong>, often called public_html.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"518\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/12\/Public-HTML-FTP.jpg\" class=\"attachment-full size-full\" alt=\"Public HTML FTP\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/12\/Public-HTML-FTP.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/12\/Public-HTML-FTP-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/12\/Public-HTML-FTP-768x411.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/12\/Public-HTML-FTP-620x331.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Then, within that directory,<strong> locate the wp-config.php file, right-click on it,<\/strong> and <strong>select the <em>View\/Edit<\/em> option<\/strong>.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"518\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/04\/Wp-Config.jpg\" class=\"attachment-full size-full\" alt=\"Wp Config\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/04\/Wp-Config.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/04\/Wp-Config-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/04\/Wp-Config-768x411.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/04\/Wp-Config-620x331.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Next, <strong>open the file<\/strong> using your preferred text editor and scroll down. Any code line(s) that you plan on inserting should be added above the \/* That&#8217;s all, stop editing! Happy blogging. *\/ comment line.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"518\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/FTP-Insert-Code-Here.jpg\" class=\"attachment-full size-full\" alt=\"FTP Insert Code Here\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/FTP-Insert-Code-Here.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/FTP-Insert-Code-Here-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/FTP-Insert-Code-Here-768x411.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/FTP-Insert-Code-Here-620x331.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]After editing the file, you should<strong> save the changes<\/strong> and <strong>upload it back to your server<\/strong> to override the file currently there.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<strong>Finding the name of your database<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]You can find a lot of valuable information on your database in general by reviewing your wp-config.php file. To find your database name, you simply need to look at the MySQL settings section found near the top of the wp-config.php file. As we noted above, you will need to <strong>select the <em>View\/Edit<\/em> option<\/strong> to access the file. Then, <strong>look for the following line of code:<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">define( 'DB_NAME', 'your-database-name-goes-here' );<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]You\u2019ll find your database name in place of the &#8216;your-database-name-goes-here&#8217; value.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"456\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/FTP-Code-Added.jpg\" class=\"attachment-full size-full\" alt=\"FTP Code Added\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/FTP-Code-Added.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/FTP-Code-Added-300x141.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/FTP-Code-Added-768x361.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/FTP-Code-Added-620x292.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]<strong>Running a MySQL query<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Queries are a type of structured command a user makes to interact with a given database. With them, you can retrieve data that matches an expression, insert new data, delete tables, rows, or fields, and much more. The most obvious and straightforward way of optimizing a database is by running adequately constructed queries.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]To run a query, you must first open the phpMyAdmin application. To do so, <strong>log in to cPanel<\/strong> using your credentials and <strong>click on the <em>phpMyAdmin<\/em> option<\/strong> located in the <em>Databases<\/em> section.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"518\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/01\/Databases-phpMyAdmin-1.jpg\" class=\"attachment-full size-full\" alt=\"Databases phpMyAdmin\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/01\/Databases-phpMyAdmin-1.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/01\/Databases-phpMyAdmin-1-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/01\/Databases-phpMyAdmin-1-768x411.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/01\/Databases-phpMyAdmin-1-620x331.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]The phpMyAdmin application will open shortly after.<strong> Locate your database<\/strong> among the list of databases on the left and <strong>click on it<\/strong> to open.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"518\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/cPanel-Access.jpg\" class=\"attachment-full size-full\" alt=\"cPanel Access\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/cPanel-Access.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/cPanel-Access-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/cPanel-Access-768x411.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/cPanel-Access-620x331.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]To run a query, <strong>switch to the <em>SQL<\/em> tab<\/strong> that is located near the top of your screen <strong>by clicking on it<\/strong>. Then,<strong> insert your MySQL query in the top section<\/strong>. After inserting it, you will notice two buttons below. <strong>Pressing the <em>Simulate query<\/em> button will allow you to perform a dry run of the query and see how many rows would be affected. Pressing the <em>Go<\/em> button will simply perform the query.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"518\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/MySQL-query.jpg\" class=\"attachment-full size-full\" alt=\"MySQL query\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/MySQL-query.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/MySQL-query-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/MySQL-query-768x411.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/MySQL-query-620x331.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Generally speaking, performing a dry run first is the recommended option, especially if you don\u2019t feel comfortable running the query straight out.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Apart from that, we need to stress that you should <strong>carefully adjust the names of the appropriate tables in the query if your <a href=\"https:\/\/qodeinteractive.com\/magazine\/how-to-change-wordpress-database-prefix\/\">default WordPress prefix has been changed<\/a>. For example, if the query contains the wp_posts table, you should replace it with yourprefix_posts. Make sure to replace the <em>yourprefix<\/em> part with your current database prefix.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;22px&#8221;]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\"><strong>Methods of manually optimizing the database<\/strong><\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Once you have a grasp on all the requirements, let\u2019s take a look at the methods you can use to manually optimize your database. Since you will be altering the content of the database using those methods, we\u2019ll warn you again about making a database backup beforehand, to prevent losing your data.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<strong>Performing database table optimization<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]To perform this database optimization method, you will need to <strong>log in to cPanel<\/strong> or a similar hosting control panel. Next, <strong>click on the <em>phpMyAdmin<\/em> option<\/strong> located in the <em>Databases<\/em> section.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"518\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/01\/Databases-phpMyAdmin-1.jpg\" class=\"attachment-full size-full\" alt=\"Databases phpMyAdmin\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/01\/Databases-phpMyAdmin-1.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/01\/Databases-phpMyAdmin-1-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/01\/Databases-phpMyAdmin-1-768x411.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/01\/Databases-phpMyAdmin-1-620x331.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]<strong>Find your database<\/strong> from the list of databases on the left and <strong>click on it<\/strong> to open. Then, <strong>select all the tables by clicking on the <em>Check all<\/em> link<\/strong> located near the bottom of the main section. After that, <strong>choose the <em>Optimize table<\/em> option<\/strong> from the dropdown next to the link.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"518\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Manually-Optimize-Tables.jpg\" class=\"attachment-full size-full\" alt=\"Manually Optimize Tables\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Manually-Optimize-Tables.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Manually-Optimize-Tables-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Manually-Optimize-Tables-768x411.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Manually-Optimize-Tables-620x331.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;60px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"518\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Optimize-Tables.jpg\" class=\"attachment-full size-full\" alt=\"Optimize Tables\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Optimize-Tables.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Optimize-Tables-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Optimize-Tables-768x411.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Optimize-Tables-620x331.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]You will need to wait a bit for the database tables to be optimized. Once it\u2019s done, you will see a success message similar to the one shown below.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"518\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Manually-Optimize-Tables-Success-Message.jpg\" class=\"attachment-full size-full\" alt=\"Manually Optimize Tables Success Message\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Manually-Optimize-Tables-Success-Message.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Manually-Optimize-Tables-Success-Message-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Manually-Optimize-Tables-Success-Message-768x411.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Manually-Optimize-Tables-Success-Message-620x331.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]<strong>Deleting post revisions<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]To reduce the number of post revisions bloating your database, you can insert the following line of code into the wp-config.php file.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">define( 'WP_POST_REVISIONS', 3 );<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]This snippet of code will reduce the number of revisions stored in your database to the most recent three for each post. If the database currently contains more revisions than that, the older ones will be deleted. You can adjust the number you use from three to any that you find suitable. However, you should know that this setting will work only for newer posts, those created and revised after adding the code snippet, and won\u2019t work on your older posts.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]If you want to completely remove all current post revisions, you can use the phpMyAdmin application to run the following query in your database:<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">DELETE FROM wp_posts WHERE post_type = \"revision\";<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]On the other hand, you can disable future post revisions altogether by inserting the following snippet of code in your wp-config.php file:<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">define( 'WP_POST_REVISIONS', false );<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Generally speaking, we advise against completely removing the revisions feature, as it could be a useful fallback. Especially if you lose connection or experience server issues, or any other type of WordPress error, while editing your posts.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]However, if you are concerned by the number of revisions, you can simply increase the autosave interval from the default 60 seconds to 360 using the snippet given below:[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">define('AUTOSAVE_INTERVAL', 360);<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]This snippet has to be inserted inside the wp-config.php file. Knowing what it does, you can adjust the number from 360 (seconds) to something more in line with your needs.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<strong>Deleting unapproved, trashed, and spam comments<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]For this method, we have three snippets to share. Each represents a different query you can run on your database using the phpMyAdmin application.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]To remove all the comments that have been marked as spam, use the following query:<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">DELETE FROM wp_comments WHERE comment_approved = 'spam';<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]To remove all trashed comments, use this query:<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">DELETE from wp_comments WHERE comment_approved = 'trash';<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]And, if you want to remove all the unapproved comments, you can use the query below:[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">DELETE FROM wp_comments WHERE comment_approved = '0';<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<strong>Removing items in the trash<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]There are two ways you can remove items from the trash. The first is to reduce the default period for keeping a deleted item in the trash before it gets permanently removed.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]This is done by inserting the following line of code to your wp-config.php file:<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">define( 'EMPTY_TRASH_DAYS', 5 );<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]It will reduce the default number of days that items are allowed to stay in the trash from 30 to 5 days. You can change this number and increase or decrease this time limit as you see fit. It\u2019s also possible to set the number 0, which will disable the trash functionality completely. However, we don\u2019t advise it, as you wouldn\u2019t be able to restore any accidentally deleted posts if you disable the trash.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]However, as we mentioned earlier, there is another method you can use to remove the trash. It involves removing all the items that are currently in the trash by running this simple query:<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">DELETE FROM `wp_posts` WHERE `post_status`=\"trash\";<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]This is done within your website\u2019s database using the phpMyAdmin application.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<strong>Deleting leftover tables<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]To delete a leftover table, you will need to <strong>log in to cPanel<\/strong> with your cPanel credentials and <strong>click on the <em>phpMyAdmin<\/em> option<\/strong>, located within the <em>Databases<\/em> section.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"518\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/01\/Databases-phpMyAdmin-1.jpg\" class=\"attachment-full size-full\" alt=\"Databases phpMyAdmin\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/01\/Databases-phpMyAdmin-1.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/01\/Databases-phpMyAdmin-1-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/01\/Databases-phpMyAdmin-1-768x411.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/01\/Databases-phpMyAdmin-1-620x331.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]After <strong>opening your database<\/strong> on the left, <strong>click on the leftover table<\/strong> you wish to remove. Unlike the WP-Optimize plugin, your database won\u2019t indicate the leftover table(s) as the plugin\u2019s interface did. However, most often, the table(s) you need will be named similarly to the plugin that was removed from your website. This will help you narrow down your search significantly.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"570\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Delete-a-Table.jpg\" class=\"attachment-full size-full\" alt=\"Delete a Table\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Delete-a-Table.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Delete-a-Table-300x176.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Delete-a-Table-768x452.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Delete-a-Table-620x365.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]After clicking on the appropriate table, you\u2019ll need to <strong>open the <em>Operations<\/em> tab<\/strong> in the section near the top of the screen. Then, <strong>click on the <em>Delete the table (DROP)<\/em> link<\/strong> below to remove the table.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"518\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Delete-a-Table-2.jpg\" class=\"attachment-full size-full\" alt=\"Delete a Table\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Delete-a-Table-2.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Delete-a-Table-2-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Delete-a-Table-2-768x411.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Delete-a-Table-2-620x331.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;60px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"460\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Delete-a-Table-3.jpg\" class=\"attachment-full size-full\" alt=\"Delete a Table\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Delete-a-Table-3.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Delete-a-Table-3-300x142.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Delete-a-Table-3-768x365.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Delete-a-Table-3-620x294.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]At this point, you will be prompted to confirm your choice. If you are sure you want to permanently remove this table and all its content from your database, <strong>press the <em>OK<\/em> button<\/strong>. The process will be done shortly after.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"518\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Delete-a-Table-Confirm.jpg\" class=\"attachment-full size-full\" alt=\"Delete a Table Confirm\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Delete-a-Table-Confirm.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Delete-a-Table-Confirm-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Delete-a-Table-Confirm-768x411.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/08\/Delete-a-Table-Confirm-620x331.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]<strong>Removing orphaned data<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]In this section, we will show you the queries you can use to delete orphaned posts and comments metadata. However, with these queries, you won\u2019t have the option of using the <em>Simulate query<\/em> button as they aren\u2019t written in a way that triggers the button display. Instead, you can use the two COUNT queries we included below:[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">SELECT COUNT(pm.meta_id) as row_count FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL;<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]And:<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">SELECT COUNT(*) as row_count FROM wp_commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM wp_comments);<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]The first query counts the number of rows within the wp_postmeta table, which don\u2019t have a valid post ID. This correlates to not having a valid ID within the wp_posts table. The second query counts the number of rows within the wp_commentmeta table, which have comment_ids that don\u2019t exist within the wp_comments table. By using the two COUNT queries above, you can simulate the outcome of performing the DELETE queries given below.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]To delete the leftover post metadata, use the following query:<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">DELETE pm FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL;<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]And, to delete the leftover comment metadata, use the following query:<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">DELETE FROM wp_commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM wp_comments);<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<span style=\"font-weight: 400;\">These DELETE queries are designed to delete the rows within wp_postmeta and wp_commentmeta tables that don\u2019t have a valid or existing ID when cross-referenced with the wp_posts and wp_comments tables.<\/span>[\/vc_column_text][vc_empty_space height=&#8221;68px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h2 class=\"qodef-h4\">Final Thoughts<\/h2>\n<p>[\/vc_column_text][vc_column_text]An optimized database is essential to keeping a WordPress website efficient and fast-performing. Database bloat is a very common issue and one that can be tackled in various ways. Most WordPress users may opt for the simplest method and use the options provided within a plugin such as the WP-Optimize. However, more advanced users can employ technical solutions to improving and optimizing the various aspects of the database. The method you decide to use is up to you. With the explanations provided in this guide, we are confident that you will be able to optimize your WordPress database quickly and efficiently.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Finally, don\u2019t forget to make a database backup beforehand as it will ensure no lasting consequences happen to your website if anything goes wrong. And, since every action within the WordPress dashboard leaves a footprint in the database, getting into the habit of regularly optimizing your database is highly recommended.<br \/>\n[\/vc_column_text][\/vc_column][\/vc_row]<\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>In this step-by-step guide, we&#8217;ll show you how to optimize your WordPress database and make your site perform better thanks to its lightened load.<\/p>\n","protected":false},"author":11229,"featured_media":28127,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[49,4,13],"class_list":["post-28122","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-database","tag-tips","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/posts\/28122","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/users\/11229"}],"replies":[{"embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/comments?post=28122"}],"version-history":[{"count":0,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/posts\/28122\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/media\/28127"}],"wp:attachment":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/media?parent=28122"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/categories?post=28122"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/tags?post=28122"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}