Why does my site have too many queries?

Discussion QuestionsCategory: ProgrammingWhy does my site have too many queries?
Zithromax asked 2 years ago
79 Views

I have tried everything possible to reduce query time and number of queries including caching, minification, gzip compression, combining js and css, etc. but the queries are still larger, 147, 247 and even 1134 respectively on SHOPFINISH, TAMFITRONICS , and TISTALENTS.
I have tried the below method from GitHub but it did not help.

Reduce database queries (http://www.catswhocode.com/blog/speeding-up-your-wordpress-blog-7-effective-solutions)
It is important to reduce unecessary queries to your database as each query take a few milliseconds to execute. First, you might want to know how many queries your blog execute in order to display a page. To do so, paste the code below in your functions.php file. Once done, just have a look to your site footer to know how many queries has been executed and how many time it took to completely load the page.

add_action( 'wp_footer', 'tcb_note_server_side_page_speed' );
function tcb_note_server_side_page_speed() {
  date_default_timezone_set( get_option( 'timezone_string' ) );
  $content  = '[ ' . date( 'Y-m-d H:i:s T' ) . ' ] ';
  $content .= 'Page created in ';
  $content .= timer_stop( $display = 0, $precision = 2 );
  $content .= ' seconds from ';
  $content .= get_num_queries();
  $content .= ' queries';
  if( ! current_user_can( 'administrator' ) ) $content = "<!-- $content -->";
  echo $content;
}
Then, you have to remove useless queries from your blog. Start by making sure that you are not using too many plugins, as most plugins are making database queries. 
Then you can remove theme-related queries that are not useful to your blog.

Any either ideas please. The queries are too much. Turning off plugins did not help either…!

Spread the love
  • 2
    Shares