Drupal:编辑文章并看到 10930 个执行的查询?
这就是 devel 的第一行告诉我的内容:
在 3177.9 毫秒内执行了 10930 个查询。耗时超过 5000 毫秒的查询和执行多次的查询会突出显示。页面执行时间为 8976.56 毫秒
这听起来很多。我应该寻找什么/哪里来找到这个问题的原因?
更新 - 这有帮助 我在 http://drupal.org/node/402944 找到了解决方案。我在 _menu_link_translate (menu.inc) 中应用了修复程序。现在我的查询数量减少到了 1500 个。
更新: 两个方法被广泛调用,并生成大量查询:
drupal_lookup_path(大约 600 个查询),形式为:
SELECT src FROM url_alias WHERE dst = 'node/81528/edit' AND language IN('da', '') ORDER BY language DESC
_ad_channel_load_node(大约 1800 个查询)。该方法查询mysql 3次。显然该方法是在node_load 上调用的。
关于缓存,我想我会开始寻找一种减少查询次数的方法。似乎有些不对劲。
PS 我是 drupal 的新手。
This is what the first line from devel tells me:
Executed 10930 queries in 3177.9 milliseconds. Queries taking longer than 5000 ms and queries executed more than once, are highlighted. Page execution time was 8976.56 ms
This sounds like a lot. What/where should I look for to find the cause of this?
UPDATE - THIS HELPED
I found a solution at http://drupal.org/node/402944. I applied the fix in _menu_link_translate (menu.inc). Now I'm down to 1500 queries.
UPDATE:
Two methods are called extensively, and generating a lot of queries:
drupal_lookup_path (around 600) queries, in the form of:
SELECT src FROM url_alias WHERE dst = 'node/81528/edit' AND language IN('da', '') ORDER BY language DESC
_ad_channel_load_node (around 1800 queries). This method queries mysql three times. Apparently the method is called on node_load.
Regarding caching, I think I would start to find a way to reduce the number of queries. Something seems to be a bit off.
P.S. I'm new at drupal.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
好吧,看看下面的查询(如果尚未启用查询显示,请启用)。尝试计算哪些函数正在执行最多和最慢的查询。然后尝试找出它们属于哪个模块以及它们在做什么。
编辑节点时会清除缓存,因此有大量数据需要重新加载。
Well, look at the queries below (enable query display if you haven't already). Try to count which functions are executing the most and slowest queries. Then try to figure out which module they belong and what they are doing.
Caches are cleared when a node is edited, so there is a large amount of data that needs to be loaded again.
Devel 还可以一一显示查询。启用此功能,重新编辑文章,保存它,然后查看具体查询。也许其中许多看起来都很相似,所以你可以开始越来越多地挖掘。
让我们更多地了解这篇文章。我猜是一个CCK节点,但是它有很多字段吗?哪一种?
Devel can also display the queries, one by one. Enable this, re-edit the article, save it and then have a look at the specific queries. Probably many of them will look similar, so you can start digging more and more.
Let us know more about the article. Is a CCK node I guess, but does it has many fields? Which kind?
这听起来像是菜单路由器的问题。清除菜单缓存后,将执行 menu_rebuild,这可以生成数千个查询,如您所描述的。这就像 Drupal http://drupal.org/node/512962
如果您提供查询示例,我们也许能够为您提供更多帮助。
This sounds like a problem with the menu router. When the menu caches are cleared, menu_rebuild is executed, which can generate many thousands of queries like you described. This is like to be an effect of this core bug in Drupal http://drupal.org/node/512962
If you give a sample of the queries we may be able to help you more.
有几件事可以使 Drupal 执行大量查询:
如果您通常只有匿名用户浏览您的网站,您可能希望使用页面缓存、压缩和压缩 CSS/JS 来测试它,这可能会减少查询次数显著地。
此外,使用 Cachegrind 和 Webgrind 等工具可以帮助识别哪些 PHP 函数需要很长时间才能执行,这有时比运行多少个 SQL 查询更有用。
There are several things that can make Drupal perform a lot of queries:
If you generally only have anonymous users browsing your site, you may wish to test it with page caching, compression and zipped CSS/JS on, which may reduce the number of queries significantly.
Also using something like Cachegrind and Webgrind can help identify which PHP functions are taking a long time to execute, which is sometimes more useful than how many SQL queries you are running.