I updated my my wp-config.php file with the following tag:
define(‘SAVEQUERIES’, true);
That command saves the query and the results of the query on a page. In addition to the above, you have to open wp-content\themes\your-theme-name\footer.php and add the following code:
<?php if (current_user_can(‘level_10’)) { global $wpdb; echo “
"; print_r($wpdb->queries); echo "
“; } ?>
This creates a table of the queries run on a page and their corresponding execution time. You can get this table by opening up any page that uses themes. Then scroll down to the bottom of the page to see the table. On my blog, there are 11 queries that it executes on the page and the total execution time for all of these 11 queries is less then .01 seconds.
Then I added the following code to the theme footer:
<?php echo get_num_queries(); ?> queries. <?php timer_stop(1); ?> seconds.
If you scroll down to the bottom of the Source text, on my page it shows that instead of the 11 queries that the SAVEQUERIES command detected, the page actually ran 15 queries. Instead of the 11 queries taking less than .01 seconds as shown by SAVEQUERIES, the 15 queries took 16.345 seconds.
I don’t know what the additional 4 queries are, but at least one of those 4 is causing a problem. I don’t know how to find out what those 4 queries are, but if any of you have an idea, maybe you could pass it on.