190 SQL queries per page
-
Hi everyone. I decided to start working on some DB optimization on my wordpress install after spending the last few weeks doing various server / site optimization.
I decided to see what the current number of queries per page were using
<?php echo $wpdb->num_queries; ?> <?php _e('queries'); ?>. <?php timer_stop(1); ?> <?php _e('seconds'); ?>
Which turned up on average 190 queries for the main page! I’ve been a professional developer for 16 years now and I’ve never had to use more then 20 – 30 queries on a single page before.
I decided to run some more tests and installed the SQL monitor plugin just to confirm and sure enough, still around 190 queries. Even with disabling all plugins and using a totally blank theme page (no get_header / get_footer, nothing) there were still about 70 queries. Using the detault wordpress theme brought this down to 40 queries.
But still! 40 queries on a default wordpress install? That can not be right can it?
I don’t know if its a problem with the database structure / data, theme, or a what at this point. Looking at the query output it seems like every single piece of data that is requested from the database is another query. So for example if I have 2 posts displayed in a catagory each with a image that is 20 queries.
Can anyone give me any suggestions? The site is large (40 catagories, 1500 tags, 3500 posts, etc) and have gone from a static site, a WU site, back to wordpress etc over the last 5 years. Should I just make a backup and restart from scratch or is this a known issue that many wordpress developers have falling into in the past?
Any feedback on where to start or suggestions are welcome. I can include any extra details that are needed as well.
- The topic ‘190 SQL queries per page’ is closed to new replies.