Support » Fixing WordPress » Number of Queries Being Run Discrepancy

  • Resolved Dominic


    Since updating to version 3.3 RC1, it seems that my database queries have increased, but I can’t be sure because I’m getting mixed messages.

    When I use <?php echo get_num_queries(); ?> it reports that it takes 45 queries to load my home page, definitely more than I would like. However, when I examine the queries using

    define( 'SAVEQUERIES', true );
    print_r( $wpdb->queries );

    I only see 18 queries listed which is about what I have come to expect. Does anyone know where this discrepancy is coming from and which one is correct?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi dominicp, I don’t have an direct answer for you, but I have developed a plugin that shows all of the queries that are running, and it also shows where at within the WordPress execution they are running. The plugin is called Memory Viewer, however it does much more then show your memory usage.

    Thanks for the tip Brad; I like you’re plugin. It’s showing 45 queries as well. By comparing it’s output against define( 'SAVEQUERIES' ); it seems the discrepancy comes entirely from the queries that are ran in the plugins_loaded hook (i.e. those queries are not shown via define( 'SAVEQUERIES' );).

    It looks like a recent update of one of my plugins has caused it to go query crazy. I’ll ask the plugin devs what happened. Thanks again.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Number of Queries Being Run Discrepancy’ is closed to new replies.