Avatar of Robert Granlund
Robert Granlund
Flag for United States of America asked on

WordPress Database and cleaning out old data

WordPress / WooCommerce Database is huge.  I'm helping with a store that over the years the database tables have become huge.  Literally millions of table entries.  Is there any way to get rid of data that is no longer needed in the postmeta table?  Is there old information that no longer needs to be stored?

I was told I can use the following in MyPHPadmin:
SELECT * FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL;
DELETE pm FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL;

Open in new window


But if I do that, will I loos anything from my WooCommerce Store?
DatabasesWordPressMySQL Server

Avatar of undefined
Last Comment
David Favor

8/22/2022 - Mon
David Johnson, CD

Is your site broken? If not why are you trying to fix something that is not broken. Unless you are absolutely 100% sure then don't change things just because you think something is wrong.
I wouldn't worry about the woocommerce database but for the Wordpress database there are several optimizations https://www.shoutmeloud.com/reduce-wordpress-database-size.html
ASKER CERTIFIED SOLUTION
David Favor

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck