• Has anyone noticed the number of queries in WordPress 2.07 and 2.1 has jumped massively.

    On this site (www.slipperybrick.com) we are seeing around 175 queries just to bring back the front page.
    (<!– 176 queries. 0.767 seconds. –>)
    I’ve looked at other WP sites like https://www.wolf-howl.com/ (WP 2.07) and see a comparable number of queries.

    Just to make sure it wasn’t the theme, we switched back to the default theme and saw our number of queries increase to around 275. Yikes!

    I could be mistaken but I believe the previous version (2.05) required fewer than 20 queries. What’s going on?

    We ended up switching hosting b/c of the excessive amount of CPU and Query time our site required with the new version of WordPress.

    Thanks in advance for any help or advice.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter pragmatic

    (@pragmatic)

    For an example of a 2.05 blog: https://www.wealthyreader.com. It has 10 queries to bring back the main page. I realize it is a less populated blog but this demonstrates the type of performance we used to see on https://www.slipperybrick.com before we upgraded to 2.07 and then to 2.10.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    I’m running 2.1 with the NewsPortal theme, and my front page returns <!-- 34 queries. 0.672 seconds. --> for me.

    I’d say that it’s not specific to 2.1 or 2.0.7, but more specific to whatever it is that you happen to be doing.

    Thread Starter pragmatic

    (@pragmatic)

    Thanks for the reply Otto42. Can you tell me how many categories you have?

    I’ve noticed that wordpress does one seperate select statement for each category and I’m trying to figure out why.

    I found my blog reduced no.Of qurry execute new version help me lot .Btw try disable related post plugin n check

    That’s odd. I have 19(?) categories, and some code that displays recent posts on the home page — and “only” 46 queries (which is better than 175+).

    OTOH, graywolf is displaying a number of in-post images on the home page, while I have one (currently); I also have no ads, references to Flickr or really much of anything else. Could it be these items that are causing the large number of queries?

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Thanks for the reply Otto42. Can you tell me how many categories you have?

    I’ve noticed that wordpress does one seperate select statement for each category and I’m trying to figure out why.

    That would make sense, my categories are very limited, whereas you have a whole lot more.

    What are these separate select statements that you see it doing? It might help to track down what’s going on.

    Thread Starter pragmatic

    (@pragmatic)

    Well, I been checking the mysql general log file and it appears most of the queries are either for options or for the categories. We have close to 200 categories and for some reason almost every category gets queried by id:

    SELECT * FROM wp_categories WHERE cat_ID = ‘125’ LIMIT 1

    And we’ll see hundreds of these on each page request.

    I’ve tried turning off all the plugins and that doesn’t seem to help. As mentioned previously, I’ve switched themes and it the problem got worse, not better.

    I’m still trying to figure out why WP needs to grab all the fields for each category.

    Thread Starter pragmatic

    (@pragmatic)

    I think I’ve tracked down where the query is coming from.

    In wp-includes\category.php Line 150:

    $_category = $wpdb->get_row("SELECT * FROM $wpdb->categories WHERE cat_ID = '$category' LIMIT 1");

    Wrapped around this code is a call to check and see if it is in the cache. If it is, get it from cache, it it is not, get it from the database. However it appears it never finds it in the cache.

    I have the enable cache line in my wp-config.php file:
    define('ENABLE_CACHE', true);
    so that should be ok.

    It appears if the cache worked correctly then this wouldn’t be a problem.

    Anybody knows if there is a problem with the caching or if there is something special you need to do in order to get the cache to work?

    Thread Starter pragmatic

    (@pragmatic)

    I think I found the answer to this:
    Remove this line from you wp-config.php file if you have it:
    define('ENABLE_CACHE', true);

    This was a legacy setting left over from a previous version. We are happily back to 25 queries to generate a page.

    Hopefully someone can learn from my mistake.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Interesting. I can’t quite see why that would work, but hey, you can’t argue with results. ??

    I agree, Otto42. I guess it’s one of those things that leaves us all amazed and delighted. LOL

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Excessive queries in WordPress 2.07 and 2.1’ is closed to new replies.