微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

加速大型数据库的“ SQL_CALC_FOUND_ROWS” SQL查询

如何解决加速大型数据库的“ SQL_CALC_FOUND_ROWS” SQL查询

|| 我正在使用一个名为Feedwordpresswordpress插件,以便在wordpress上运行类似网站的星球(在此处查看)。 该插件很不错,除了一件事-它大约每周一次将我的(VPS)服务器关闭到提交状态。 在与网络管理员的最近电子邮件交流中,他写道:   它看起来确实像增加MysqL   资源使用缓慢造成的   由r-bloggers.com运行的查询。   这是一些日志的副本   正在生产。你会   需要优化此网站,并   数据库进一步使其运行为   尽可能有效。如果这些   更改已经完成,您的   最好的选择是调查   由于   高水平或资源和流量   网站需要和看到的内容。 以下是日志:
# Time: 110614 16:11:35
# User@Host: rblogger_rblogr[rblogger_rblogr] @ localhost []
# Query_time: 104 Lock_time: 0 Rows_sent: 0 Rows_examined: 54616
SELECT sql_CALC_FOUND_ROWS wp_rb_posts.* FROM wp_rb_posts WHERE 1=1 AND ((guid = \'235cbefa4424d0cdb7b6213f15a95ded\') OR (guid = \'http://www.r-bloggers.com/?guid=235cbefa4424d0cdb7b6213f15a95ded\') OR (guid = \'http://www.r-bloggers.com/?guid=235cbefa4424d0cdb7b6213f15a95ded\') OR (MD5(guid) = \'235cbefa4424d0cdb7b6213f15a95ded\')) AND wp_rb_posts.post_type IN (\'post\',\'page\',\'attachment\',\'revision\',\'nav_menu_item\') AND (wp_rb_posts.post_status = \'publish\' OR wp_rb_posts.post_status = \'future\' OR wp_rb_posts.post_status = \'draft\' OR wp_rb_posts.post_status = \'pending\' OR wp_rb_posts.post_status = \'trash\' OR wp_rb_posts.post_status = \'auto-draft\' OR wp_rb_posts.post_status = \'inherit\' OR wp_rb_posts.post_status = \'private\') ORDER BY wp_rb_posts.post_date DESC LIMIT 1570,10;
# User@Host: rblogger_rblogr[rblogger_rblogr] @ localhost []
# Query_time: 237 Lock_time: 0 Rows_sent: 0 Rows_examined: 54616
SELECT sql_CALC_FOUND_ROWS wp_rb_posts.* FROM wp_rb_posts WHERE 1=1 AND ((guid = \'235cbefa4424d0cdb7b6213f15a95ded\') OR (guid = \'http://www.r-bloggers.com/?guid=235cbefa4424d0cdb7b6213f15a95ded\') OR (guid = \'http://www.r-bloggers.com/?guid=235cbefa4424d0cdb7b6213f15a95ded\') OR (MD5(guid) = \'235cbefa4424d0cdb7b6213f15a95ded\')) AND wp_rb_posts.post_type IN (\'post\',\'nav_menu_item\') AND (wp_rb_posts.post_status = \'publish\' OR wp_rb_posts.post_status = \'future\' OR wp_rb_posts.post_status = \'draft\' OR wp_rb_posts.post_status = \'pending\' OR wp_rb_posts.post_status = \'trash\' OR wp_rb_posts.post_status = \'auto-draft\' OR wp_rb_posts.post_status = \'inherit\' OR wp_rb_posts.post_status = \'private\') ORDER BY wp_rb_posts.post_date DESC LIMIT 570,10;
# Time: 110614 16:18:13
# User@Host: rblogger_rblogr[rblogger_rblogr] @ localhost []
# Query_time: 257 Lock_time: 0 Rows_sent: 0 Rows_examined: 54616
SELECT sql_CALC_FOUND_ROWS wp_rb_posts.* FROM wp_rb_posts WHERE 1=1 AND ((guid = \'956e208f101562f6654e88e9711276e4\') OR (guid = \'http://www.r-bloggers.com/?guid=956e208f101562f6654e88e9711276e4\') OR (guid = \'http://www.r-bloggers.com/?guid=956e208f101562f6654e88e9711276e4\') OR (MD5(guid) = \'956e208f101562f6654e88e9711276e4\')) AND wp_rb_posts.post_type IN (\'post\',10;
# Time: 110614 16:19:02
# User@Host: rblogger_rblogr[rblogger_rblogr] @ localhost []
# Query_time: 83 Lock_time: 0 Rows_sent: 0 Rows_examined: 54616
SELECT sql_CALC_FOUND_ROWS wp_rb_posts.* FROM wp_rb_posts WHERE 1=1 AND ((guid = \'6c589e661f03a67b0529fab2f080bfd3\') OR (guid = \'http://www.r-bloggers.com/?guid=6c589e661f03a67b0529fab2f080bfd3\') OR (guid = \'http://www.r-bloggers.com/?guid=6c589e661f03a67b0529fab2f080bfd3\') OR (MD5(guid) = \'6c589e661f03a67b0529fab2f080bfd3\')) AND wp_rb_posts.post_type IN (\'post\',\'nav_menu_item\') AND (wp_rb_posts.post_status = \'publish\' OR wp_rb_posts.post_status = \'future\' OR wp_rb_posts.post_status = \'draft\' OR wp_rb_posts.post_status = \'pending\' OR wp_rb_posts.post_status = \'trash\' OR wp_rb_posts.post_status = \'auto-draft\' OR wp_rb_posts.post_status = \'inherit\' OR wp_rb_posts.post_status = \'private\') ORDER BY wp_rb_posts.post_date DESC LIMIT 1440,10;
这就引出我的问题-该日志中的哪些内容可能向我指示正在发生的事情(为什么这样的查询要花这么长时间?)?有可能优化这些吗?如果是这样,怎么办? 谢谢, 塔尔     

解决方法

        熟悉WordPress,我认为您应该在该主题的正在进行中添加一张票证,或者创建一个新票证。 http://core.trac.wordpress.org/ticket/10469 http://core.trac.wordpress.org/ticket/10964 http://core.trac.wordpress.org/search?q=SQL_CALC_FOUND_ROWS 或者,放弃该任务并使用更合适的工具。     

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。