开发者

Drupal: Editing article and seeing 10930 executed queries?

This is what the first line from devel tells me:

Executed 10930 queries in 3177.9 millisecon开发者_开发技巧ds. 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.


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 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?


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.


There are several things that can make Drupal perform a lot of queries:

  1. Rebuilding the menu router, either on a cache clear or another similar function.
  2. Lots of modules installed.
  3. Theme registry being rebuilt on every page (some themes have this setting)

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜