The wp_posts and wp_postmeta database tables on my site are huge

How Can We Help?

The wp_posts and wp_postmeta database tables on my site are huge

You are here:
< Back

We would expect on any site for our plugin to produce more pages and meta data entries than any other type of content since you have say around 100 properties this is equivalent tp one “wp_post” entry for each property and each property has it’s property data stored in “wp_postmeta” which includes around 20 entries for each property post (address details, pricing, features etc are all post meta).  Then finally we have property images which are also stored in the wp_posts table and each property might have many images (we generally go on a multiple of 10 per property, so for 100 properties expect around 1000 media entries).  We use all the standard data structures in WordPress because this means our plugin is compatible with other WordPress plugins and Themes.  It would be much more efficient to build our own data structures but then all the property data would sit outside of WordPress and be very hard to work with.

If even given these figures the sizes of the database tables seem excessively large it may be that removal of old properties or property images is not happening as it should.  We use the force delete options when removing expired property posts (and their images) from WordPress which “should” remove all traces of the property and related postmeta and images (if they are only connected to the property*).  WordPress doesn’t automatically remove images that are related for posts as it assumes they may be used in other posts but we do use a force remove option on related images to overcome this.  Sometimes, other plugin prevent this from happening or WordPress just simply ignores the force delete option, in which case you could end up with a growing database tables.  Unfortunately, we have no control over this but there are a couple of things you can try.

First, there are many plugins around that will look for orphaned images/media (images that are not attached to any posts) and will remove those images.  We would suggest that you add one to your site and run it to remove any orphaned property images.  This in itself may resolve your database size issues.

Secondly if that doesn’t help, you can go into wp-admin > Settings > WP Property Feed > Debug tab and click the “Purge all property data” button.  This will attempt to force remove all the existing property data (including images) from the database.  Obviously if you do do this it’s best to attempt at a time when the site is quiet as it will remove all current listings, and once complete you would need to run a force refresh on your property feed to reload the listings.

ADDITIONAL INFO:

If you see a 504, 404 page when trying to use the purge property function it is likely it has timed out.  If you just go back and re-submit the purge again and again you should find that the properties eventually all properties get removed.  Whilst doing this it is a good idea to suspend the property feed update – just temporarily remove the feed credentials to do that.  What you can also do it open two browser windows, one with the currently list of properties in wp-admin and the other on the purge properties page.  When you click the purge button go back to the other window and refresh again and again and you should see the list of properties reducing in size (that way you can have some confidence that the process is happening) at the same time you can do the same with the media library and you should see this reducing in size also as property images are removed.

Media Cleaner Plugin

We recommend installing the plugin “Media Cleaner” to check your media files are only the ones you should be keeping.  Media cleaner has a setting in the “Extra Rules” for “Attached Images” which you should tick as property images are attached to their related property but do not appear in the main content section so will appear as “no longer in use” if this box is not ticked.  Run a scan and remove any unused images.  Just be careful and follow the instructions (take note of backups and page builders if you are using Elementor or similar as you will need the pro version for that).