Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

My site is reaching CPU limits all the time, I just ran Debug Queries and got more than 4000 queries, no wonder site is slow.

share|improve this question
1  
Whats your permalink structure? –  MartinJJ May 8 '11 at 10:29
    
/posts/%category%/%postname%/ –  John May 8 '11 at 11:21
1  
most of the queries are related to rewrite rules, are you using any plugin that is related to that? and cache plugin? –  Bainternet May 8 '11 at 11:30

3 Answers 3

I would bet my bottom $ that the permalinks are the problem, your link shows a heck of a lot wp_rewrite queries.. take a look at this a similar issue

share|improve this answer
    
I put the post id first and then the post name second and now the thousands of queries are no more. So the situation is much better thanks. –  John May 8 '11 at 17:29
    
be sure to implement a 301 redirect on any pages indexed, –  MartinJJ May 9 '11 at 7:03

Standard permalink advice is to not start with postnames, tags, categories or authors:

From the Codex on Permalinks

For performance reasons, it is not a good idea to start your permalink structure with the category, tag, author, or postname fields. The reason is that these are text fields, and using them at the beginning of your permalink structure it takes more time for WordPress to distinguish your Post URLs from Page URLs (which always use the text "page slug" as the URL), and to compensate, WordPress stores a lot of extra information in its database (so much that sites with lots of Pages have experienced difficulties). So, it is best to have at least two path segments in your post's permalink structure such as /%year%/%postname%/ or even /posts/%postname%/. (Some people recommend /%post_id%/%postname%/ which works for performance reasons but others recommend against it because it is unfriendly to users in the many contexts in which users interact with URLs.) See Otto's technical writeup on the topic as well as this wp-testers discussion.

share|improve this answer

How many pages do you have? Pages.. not posts.

I'd have the same problem in the past with a site with a LOT of pages.

It's even documented as a bug.

If it is your case, try setting $use_verbose_page_rules to false in the WP_rewrite class

Edit: Class WP_Rewrite bool $use_verbose_page_rules = true Whether to write every mod_rewrite rule for WordPress pages.

since: 2.5.0 access: public

To change it, try (not tested):

add_action( 'rewrite_rules_array','changeVerboseRules' );

function changeVerboseRules(){
    global $wp_rewrite;
    $wp_rewrite->use_verbose_page_rules = false;
}

Anyway, this is a hack. You should read this.

share|improve this answer
    
thanks what does that variable do and where should I insert it? I have around 310 pages –  John May 8 '11 at 17:28
    
I edited the entry with an example –  MZAweb May 8 '11 at 19:38
    
Thanks Daniel will try that out. –  John May 9 '11 at 6:57
    
Don't forget to comment... Did it work? –  MZAweb May 9 '11 at 20:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.