WooCommerce的问题太大数据库大小,尤其是post_meta

发布于 2025-01-28 01:03:27 字数 910 浏览 6 评论 0 原文

我有一个大约10K产品的WooCommerce网站,但有5.1 GIB数据库的大小,而POST_META仅占用4.5 GIB,但WP_POSTS表仅为350 MB。

我尝试了以下查询,但仍然没有帮助:

**Deleting orphaned Post Meta in WordPress**

SELECT * FROM wp_postmeta pm
LEFT JOIN wp_posts wp ON wp.ID = pm.post_id
WHERE wp.ID IS NULL

OR 

SELECT * FROM wp_postmeta pm
LEFT JOIN wp_posts wp ON wp.ID = pm.post_id
WHERE wp.ID NOT IN (SELECT ID FROM wp_posts)
**Identify attachment metadata whose posts were deleted**

SELECT * 
FROM wp_posts 
WHERE 
  -- the attachments
  post_type = 'attachment' 
  AND (
    -- ignore anything without a parent
    post_parent != 0 
    -- filter on anything that has a parent that does not exist
    AND post_parent NOT IN (SELECT ID FROM wp_posts)
  )

仍然没有帮助,请让我知道如何优化WP_POSTMETA表?

我有很多属性,因此此_Product_Attributes序列化数据对于每个产品来说都太大了。如果我们已经有条款和分类表,为什么他们需要在_product_attributes post_meta上再次保存。 :(

I have a Woocommerce site with around 10K products but got a 5.1 GiB database size and post_meta only occupy 4.5 GiB but the wp_posts table is 350 MB only.

I have tried the following query but still not helping:

**Deleting orphaned Post Meta in WordPress**

SELECT * FROM wp_postmeta pm
LEFT JOIN wp_posts wp ON wp.ID = pm.post_id
WHERE wp.ID IS NULL

OR 

SELECT * FROM wp_postmeta pm
LEFT JOIN wp_posts wp ON wp.ID = pm.post_id
WHERE wp.ID NOT IN (SELECT ID FROM wp_posts)
**Identify attachment metadata whose posts were deleted**

SELECT * 
FROM wp_posts 
WHERE 
  -- the attachments
  post_type = 'attachment' 
  AND (
    -- ignore anything without a parent
    post_parent != 0 
    -- filter on anything that has a parent that does not exist
    AND post_parent NOT IN (SELECT ID FROM wp_posts)
  )

Still not helping, please let me know how I can optimize the wp_postmeta table?

I have lots of attributes so this _product_attributes serialized data is too big for each product. If we already got terms and taxonomy table why do they need to save again on _product_attributes post_meta. :(

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

耳钉梦 2025-02-04 01:03:27

POST_META (在WordPress或WooCommerce中)的索引效率低下。建议您添加此插件: wp index改进 < /a>

更多讨论:

(从任何大表中删除未使用的数据很少有助于改善索引。)

post_meta (in WordPress or WooCommerce) is inefficiently indexed. Suggest you add this plugin: WP Index Improvements

More discussion: http://mysql.rjweb.org/doc.php/index_cookbook_mysql#speeding_up_wp_postmeta

(Deleting unused data from any big table rarely helps as much as improving the indexes.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文