用户工具

站点工具


侧边栏

Hi,大家好,我叫尹佳冀。我是一个热爱太极的程序员!

导航

wordpress_remove_revisions

移除Wordpress的Revision

wordpress的的revision功能 会产生慢查询

Count: 637684  Time=19.43s (12387815s)  Lock=0.04s (23212s)  Rows_sent=6.0 (3825972), Rows_examined=129548.8 (82611224762), fagaodata[fagaodata]@localhost
  # Rows_affected: N
  SET timestamp=N;
  SELECT SQL_CALC_FOUND_ROWS  wp_posts.ID FROM wp_posts  LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE N=N  AND wp_posts.ID NOT IN (N) AND (
  wp_term_relationships.term_taxonomy_id IN (N)
  ) AND wp_posts.post_type = 'S' AND (wp_posts.post_status = 'S') GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT N, N

如果需要去除这个慢查询,并且你的网站不依赖revisions功能。可以做如下操作

1. 禁止掉revision

在wp-config.php中添加

define ('WP_POST_REVISIONS', 0); 

2. 删除旧的revision数据

在mysql中执行

DELETE a,b,c
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = 'revision'

3. 如果你还想提高wordpress的运行内存的话

在wp-config.php 的开头添加

define('WP_MEMORY_LIMIT', '512M'); //你可以改成你想要的大小

参考资料:Wordpress 移除revision,提高性能

wordpress_remove_revisions.txt · 最后更改: 2020/07/22 20:56 (外部编辑)