Support » Plugins » [Plugin: WP Archive-Sitemap Generator] This plugin makes a lot of database queries

  • Hi

    I have just tried this plugin out as a potential alternative to DD sitemap generator.

    One thing I noticed about both plugins is the crazy amount of mysql queries required to build the sitemap.

    For a normal page load on my site wordpress makes around 50 mysql queries in total. For a page load on my Archive Sitemap page the total number of queries rockets up to over 700!!!

    The reason I wanted to switch from DD sitemap plugin is that the number of queries it makes is also very high.

    On a high traffic site with a lot of posts / pages this can cause performance issues, especially when a crawler hits all of your sitemap pages one after the other.

    Is there any way to achieve the same effect with fewer queries? As my site grows with more posts and pages will the number of queries needed to generate the sitemap grow too?

    Thanks,
    Sam

    http://wordpress.org/extend/plugins/wp-archive-sitemap-generator/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter sammyb

    (@sammyb)

    I have realised that it makes one big query, returning all posts from the db and then runs a foreach loop on the returned array of posts making one additional query per post:

    $sql = "SELECT * FROM " . $table_prefix . "posts " . $sqlwhere . $sqlorder;
    		$allposts = $wpdb->get_results($sql);
    
    		$postcounter = 0;
    		$postheader = "BLOG SITEMAP:";
    		$postend = "WP Archive-Sitemap Generator";
    		foreach($allposts as $ap)
    		{
    			$perma = get_permalink($ap->ID);
    			//$perma = sanitize_title($ap->post_title);
    			$postcounter++;
    			$posts = '<b>' . $postcounter . '.</b>&nbsp;&nbsp;' . '<a href=' . $perma . '>' . $ap->post_title . '</a>';

    If you have 15000 posts on your site how many queries will this plugin make for each sitemap page?

    The SELECT * query with no limit set will end up in the slow query log for sure on bigger sites with many posts & pages.

    Thanks for suggestion sammyb. I’ll implement this change in next release.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: WP Archive-Sitemap Generator] This plugin makes a lot of database queries’ is closed to new replies.