My WordPress sites starting to become slower by time, after two years they become very slow. I tried many things, such as:

  • improved my DB,
  • used cache plugins (WP Rocket and W3 Total Cache) which both are great, rocket is a little better but you have to pay for it,
  • checked effects of analytics on my site (deactivating slimstat analytic improved my response time by 20%),
  • handling heart beat (WP Rocket has a way to control heart beat).

Finally I checked core tables of WordPress (wp_posts and wp_postmeta) the main reason that my WordPress site is slow is because of the wp_postmeta, and unfortunately WooCommerce save its meta in the wp_postmeta which affects response time drastically.

All of these aside, there is one more thing that has strong affect on the speed, and that is the length of _wp_attachment_metadata which for my site is more that 1024 character.

How could I optimized this (_wp_attachment_metadata) metadata without loosing all the sizes which I need?

Finally if I change the type of meta_value of wp_postmeta from longtext to varchar(2024) (which I assume all plugins produce meta data with less characters) and then index it. Would it make any problem with core of WordPress?

  • 1
    How many rows are there in wp_posts and wp_postmeta? Have you done any profiling to check, which queries are slow? – Krzysiek Dróżdż Jan 6 '19 at 11:45
  • there are over 40000 posts and about half million postmeta, yes I checked all queries,(using wordpress.org/plugins/query-monitor - The query Monitor Plugin) and I optimized all possible queries. and the only thing that I can't do anything about is, _wp_attachment_metadata, but on a localhost (test environment) I did this query: "DELET FROM wp_postmeta where char_length(meta_value)>2024" and it deleted about 800 rows, yet improved my response time very effectively. That's why I'm looking for a way to reduce the size of meta_value of _wp_attachment_metadata – Arash Rabiee Jan 6 '19 at 20:39
  • Are these 40,000 unique posts, or do you have a lot of post revisions? If revisions are enabled, just disabling them or removing the current revisions will save a lot of space. – WebElaine Jan 7 '19 at 14:14
  • These are unique posts – Arash Rabiee Jan 7 '19 at 19:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.