Minimize Database queries.
-
Hi…I am using the following WP_Query code 6 times in my sidebar to show posts from 6 different categories A,B,C,D,E,F.
<?php $my_query = new WP_Query(‘category_name=A&showposts=10’);
while ($my_query->have_posts()) : $my_query->the_post(); ?>
“><?php the_title(); ?>
<?php endwhile; ?>and similarly for categories B,C,D,E and F.
When this code is executed 6 times separately to query posts. The number of database queries is 42. 7 queries each time this code is executed. I am testing this locally on my PC using XAMPP.
My Question is it good to use this code 6 times separately. Or is there a better way of doing it to minimize the number of database queries for better speed. My homepage loads in almost 2secs using 85+ queries(No-Plugins). Which I have read is not good speed testing locally on XAMPP.
- The topic ‘Minimize Database queries.’ is closed to new replies.