2012-04-10 61 views
1

我在WordPress安裝時遇到了一些性能問題。我已經運行了多個慢速查詢測試,雖然我看到它們之間有一定的一致性,但我仍然無法找出問題所在。下面是查詢的幾個是我見過多次:如何分析WordPress安裝的慢查詢日誌?

SET timestamp=1333980631; 
SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND (wp_term_relationships.term_taxonomy_id IN (1442,4054)) AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 2; 

### 1 Query 
### Total time: 3.015405, Average time: 3.015405 
### Taking 3.015405 seconds to complete 
### Rows analyzed 60 
SET timestamp=XXX; 
SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE XXX=XXX AND (wp_term_relationships.term_taxonomy_id IN (XXX)) AND wp_posts.post_type = 'XXX' AND (wp_posts.post_status = 'XXX') GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT XXX, XXX; 

SET timestamp=1334004964; 
SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND (wp_term_relationships.term_taxonomy_id IN (125)) AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish') GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 8; 

### 1 Query 
### Total time: 1.593301, Average time: 1.593301 
### Taking 1.593301 seconds to complete 
### Rows analyzed 19755 
SET timestamp=XXX; 
SELECT /*!XXX SQL_NO_CACHE */ * FROM `wp_posts`; 

SET timestamp=1333978522; 
SELECT /*!40001 SQL_NO_CACHE */ * FROM `wp_posts`; 

我注意到wp_term_taxonomy似乎來了,與wp_posts一起,和其他一些。我的問題是,我如何縮小這些結果並找出問題?

回答

3

,您可以:

  1. 使用plugin performance profiler到基準並查明問題羣插件
  2. 使用new relic發現的問題
  3. 使用Debug Objects轉儲進行查詢等

查詢您的數據顯示看起來像通常的wp-admin查詢,或者尋呼機查詢來定義在列表上顯示多少頁面。

您還可以嘗試最簡單的方法 - 逐個禁用插件以確定哪個插件會生成有問題的查詢。

+0

謝謝!我今天會研究這個。 – Ryan 2012-04-10 17:12:50