Title: Please optimize the code generating Sitemap
Last modified: January 27, 2025

---

# Please optimize the code generating Sitemap

 *  Resolved [tiptinker](https://wordpress.org/support/users/snowbedding/)
 * (@snowbedding)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/please-optimize-the-code-generating-sitemap/)
 * When we have over 10k posts, the sitemap generation takes very long time, even
   crash.

Viewing 9 replies - 1 through 9 (of 9 total)

 *  [J Burns](https://wordpress.org/support/users/subiewrx/)
 * (@subiewrx)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/please-optimize-the-code-generating-sitemap/#post-18268650)
 * Hi [@snowbedding](https://wordpress.org/support/users/snowbedding/),
 * Thanks for reaching out and I’m sorry you’re experiencing an issue with your 
   sitemap generation.
 * Could you please tell me what you Links Per Sitemap settings is set to?
   [https://a.supportally.com/i/cbFa4O](https://a.supportally.com/i/cbFa4O)
   If it is set to higher than the default value, could you please try decreasing
   it?If you’re still experiencing an issue, would it be possible to share the WordPress
   error log files?
 * You can get this log file by following these steps:
 * 1. Connect to your web server using FTP. We have an article on how to use FTP
   here – [https://aioseo.com/docs/how-to-ftp-to-your-web-server/](https://aioseo.com/docs/how-to-ftp-to-your-web-server/)
   
   2. Edit the **wp-config.php** file.3. Near the bottom of the file, you’ll see
   the following:
 * define(‘WP_DEBUG’, false);
   4. Change that line to these three lines:
 * define( ‘WP_DEBUG’, true ); define( ‘WP_DEBUG_LOG’, true ); define( ‘WP_DEBUG_DISPLAY’,
   false );
   5. Reproduce the error or problem on your site so an error is logged.
   6. Using FTP on your web server, navigate to the **/wp-content** directory and
   look for the **debug.log** file.7. Download that file to your local computer.
   8. You can then change your wp-config file back to its original settings.
 * Please send that debug log file to me so that I can look into this issue.
 *  Thread Starter [tiptinker](https://wordpress.org/support/users/snowbedding/)
 * (@snowbedding)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/please-optimize-the-code-generating-sitemap/#post-18268922)
 * I noticed that you display all urls of WPML languages in the sitemap, maybe this
   is the cause.
 * Can we have an option to hide WPML languages in sitemap?
 *  [J Burns](https://wordpress.org/support/users/subiewrx/)
 * (@subiewrx)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/please-optimize-the-code-generating-sitemap/#post-18273473)
 * Hi [@snowbedding](https://wordpress.org/support/users/snowbedding/),
 * Could you please check your AIOSEO sitemap settings to ensure the indexes are
   enabled and set to 1000 URLs as seen here- [https://a.supportally.com/i/aj0CJy](https://a.supportally.com/i/aj0CJy)
   
   Could you also share your site URL so I can take a closer look?
 * Thanks!
 *  Thread Starter [tiptinker](https://wordpress.org/support/users/snowbedding/)
 * (@snowbedding)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/please-optimize-the-code-generating-sitemap/#post-18273978)
 * Here is the slowlog of mysql, could you please help me find out the issue
 *     ```wp-block-code
       # Time: 2025-01-30T07:05:07.592304Z# User@Host: hellokitty[hellokitty] @ localhost []  Id:    20# Schema: kitty  Last_errno: 0  Killed: 0# Query_time: 8.860641  Lock_time: 0.000004  Rows_sent: 10  Rows_examined: 117988  Rows_affected: 0  Bytes_sent: 40507use kitty;SET timestamp=1738220698;SELECT 	p.ID, p.post_type, p.post_content, p.post_excerpt, p.post_modified_gmtFROM fwfbed_posts as p	LEFT JOIN 111_aioseo_posts as ap ON ap.post_id = p.IDWHERE 1 = 1 AND	( ap.id IS NULL OR p.post_modified_gmt > ap.image_scan_date OR ap.image_scan_date IS NULL )	AND p.post_status IN ( 'publish', 'inherit' )	AND p.post_type IN ( 'post', 'page', 'attachment', 'product', 'zn_layout', 'portfolio', 'documentation', 'znpb_template_mngr' )LIMIT 10/* 1 = 1 */;# Time: 2025-01-30T07:06:08.267060Z# User@Host: hellokitty[hellokitty] @ localhost []  Id:    66# Schema: kitty  Last_errno: 0  Killed: 0# Query_time: 3.110860  Lock_time: 0.000002  Rows_sent: 500  Rows_examined: 132586  Rows_affected: 0  Bytes_sent: 1456860SET timestamp=1738220765;SELECT 	p.ID, p.post_title, p.post_content, p.post_excerpt, p.post_type, p.post_password, p.post_parent, p.post_date_gmt, p.post_modified_gmt, ap.priority, ap.frequency, ap.imagesFROM fwfbed_posts as p	LEFT JOIN 111_aioseo_posts as ap ON ap.post_id = p.IDWHERE 1 = 1 AND	p.post_status = 'publish'	AND p.post_type IN ( 'post' )	AND ( ap.robots_noindex IS NULL OR ap.robots_default = 1 OR ap.robots_noindex = 0 OR post_id = 605 )	AND 1=1 OR p.ID = 606ORDER BY case when p.ID = 606 then 0 else 1 end, ap.priority DESC, p.post_modified_gmt DESCLIMIT 10000, 500/* 1 = 1 */;
       ```
   
 *  Plugin Support [Prabhat](https://wordpress.org/support/users/prabhatrai/)
 * (@prabhatrai)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/please-optimize-the-code-generating-sitemap/#post-18277802)
 * Hey [@snowbedding](https://wordpress.org/support/users/snowbedding/),
 * Thanks for sharing the logs.
 * I checked the logs you’ve shared, and it appears that the **Links Per Sitemap**
   value is set to 10,000 or above under **All in One SEO > Sitemaps** –
 * [https://aioseo.com/docs/how-to-create-an-xml-sitemap/#:~:text=We%20limit%20each%20sitemap%20page%20to%201%2C000%20URLs.%20If%20you%20have%20more%20than%201%2C000%20URLs%20for%20any%20type%20of%20content%2C%20we%27ll%20split%20the%20sitemap%20into%20pages%2C%20with%201%2C000%20URLs%20in%20each%20page](https://aioseo.com/docs/how-to-create-an-xml-sitemap/#:~:text=We%20limit%20each%20sitemap%20page%20to%201%2C000%20URLs.%20If%20you%20have%20more%20than%201%2C000%20URLs%20for%20any%20type%20of%20content%2C%20we%27ll%20split%20the%20sitemap%20into%20pages%2C%20with%201%2C000%20URLs%20in%20each%20page).
 * We recommend setting this option’s value to 1000 as a big value can affect the
   loading time and negatively affect your Sitemap.
 * Could you please go to **All in One SEO > Sitemaps** and ensure that the **Links
   Per Sitemap** value is set to **1000** and the **Enable Sitemap Indexes** option
   is set to **Enabled**?
 * Once done, clear your website and browser’s cache and see if the Sitemap loads
   correctly.
 * If the issue persists, please share your website’s URL as requested by my colleague
   so I can investigate further. Additionally, please share a screenshot of all 
   the settings under **All in One SEO > Sitemaps** so I can take a closer look 
   at the issue.
 * If you want, you can also email us the details at [support@aioseo.com](https://wordpress.org/support/topic/please-optimize-the-code-generating-sitemap/support@aioseo.com?output_format=md).
 * I’m really looking forward to helping you.
 *  Thread Starter [tiptinker](https://wordpress.org/support/users/snowbedding/)
 * (@snowbedding)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/please-optimize-the-code-generating-sitemap/#post-18278410)
 * Hi, thank you for your help.
 * I set the limit to 500 urls per sitemap.
 * I can now open it.
 * I still hope there is an option to hide WPML links in sitemap, because we have
 * <link rel=”alternate” hreflang=”es”
 * in head tag.
 * Google will find them.
 * ![](https://wordpress.org/81d4e56b-b421-487d-b57d-32a867864a1e)
 *  Plugin Author [arnaudbroes](https://wordpress.org/support/users/arnaudbroes/)
 * (@arnaudbroes)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/please-optimize-the-code-generating-sitemap/#post-18296065)
 * Hey [@snowbedding](https://wordpress.org/support/users/snowbedding/),
 * I’ve added a new filter hook to our next release, version 4.8.0, which you can
   use to disable sitemap localization. If you add this code snippet in your theme’s
   functions.php file or through a plugin like WPCode, then it should stop including
   them.
 * `add_filter( 'aioseo_sitemap_localization_disable', '__return_true' );`
 *  Thread Starter [tiptinker](https://wordpress.org/support/users/snowbedding/)
 * (@snowbedding)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/please-optimize-the-code-generating-sitemap/#post-18297264)
 * When will it be released?
 *  Plugin Author [arnaudbroes](https://wordpress.org/support/users/arnaudbroes/)
 * (@arnaudbroes)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/please-optimize-the-code-generating-sitemap/#post-18306951)
 * We’re looking to release on Feb 27 which is approximately two weeks from now.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Please optimize the code generating Sitemap’ is closed to new replies.

 * ![](https://ps.w.org/all-in-one-seo-pack/assets/icon.svg?rev=2443290)
 * [All in One SEO – Powerful SEO Plugin to Boost SEO Rankings & Increase Traffic](https://wordpress.org/plugins/all-in-one-seo-pack/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/all-in-one-seo-pack/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/all-in-one-seo-pack/)
 * [Active Topics](https://wordpress.org/support/plugin/all-in-one-seo-pack/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/all-in-one-seo-pack/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/all-in-one-seo-pack/reviews/)

 * 10 replies
 * 4 participants
 * Last reply from: [arnaudbroes](https://wordpress.org/support/users/arnaudbroes/)
 * Last activity: [1 year, 3 months ago](https://wordpress.org/support/topic/please-optimize-the-code-generating-sitemap/#post-18306951)
 * Status: resolved