How to empty the wp_postmeta table of your WordPress

Procédure

How to empty the wp_postmeta table if it is taking up a large amount of space

If you have been using WordPress for a while, it is likely that your wp_postmeta table is quite large.
This article will explain how to clean the wp_postmeta table in order to reduce the size of your WordPress database

How to empty the wp_postmeta table if it is taking up a large amount of space:

To reduce the size of the wp_postemeta table, you will need to execute MySQL queries. To run these queries, you must connect to PhpMyAdmin, then click on the SQL tab, paste the desired query into the field and press the Execute button

  • To delete revisions: 
DELETE FROM `wp_posts` WHERE `post_type`="revision"
  • To delete deleted posts (found in the trash):
DELETE FROM `wp_posts` WHERE `post_status`="trash"
  • To delete orphan posts:
DELETE m FROM `wp_postmeta` AS m
LEFT JOIN `wp_posts` AS p ON m.`post_id` = p.`ID`
WHERE p.`ID` IS NULL

Conclusion:

You are now able to clean the wp_postmeta table, which helps reduce the size of your MySQL database.
This will allow you to delete unnecessary data from your database and thus reduce its size.
Feel free to contact our technical support team via an incident ticket for any questions.

help.lws.net/a/1341
Was this article helpful?

Yes

No

Read 23 841 times

Thank you! Feel free to ask questions about our documentation if you would like more information, and help us improve it.

Similar articles

A question about this article?

Ask the LWS team and the community. Answers are published after moderation.

Ask the LWS team and its community a question

GDPR: Controller: LWS-Ligne Web Services. Purpose: moderation and public publication of your question, possible notification of an answer. Legal basis: consent (Art. 6(1)(a) GDPR). Email retention: 90 days after notification, 12 months maximum without an answer. To exercise your rights, see the GDPR section of our Terms and Conditions.