Please optimize the code generating Sitemap
-
When we have over 10k posts, the sitemap generation takes very long time, even crash.
-
Hi @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 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/
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.
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?
Hi @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
Could you also share your site URL so I can take a closer look?Thanks!
Here is the slowlog of mysql, could you please help me find out the issue
# 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: 40507
use kitty;
SET timestamp=1738220698;
SELECT
p
.ID
,p
.post_type
,p
.post_content
,p
.post_excerpt
,p
.post_modified_gmt
FROM fwfbed_posts as p
LEFT JOIN 111_aioseo_posts as ap ONap
.post_id
=p
.ID
WHERE 1 = 1 AND
(ap
.id
IS NULL ORp
.post_modified_gmt
>ap
.image_scan_date
ORap
.image_scan_date
IS NULL )
ANDp
.post_status
IN ( 'publish', 'inherit' )
ANDp
.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: 1456860
SET 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
.images
FROM fwfbed_posts as p
LEFT JOIN 111_aioseo_posts as ap ONap
.post_id
=p
.ID
WHERE 1 = 1 AND
p
.post_status
= 'publish'
AND p.post_type IN ( 'post' )
AND (ap
.robots_noindex
IS NULL ORap
.robots_default
= 1 ORap
.robots_noindex
= 0 OR post_id = 605 )
AND 1=1 ORp
.ID
= 606
ORDER BY case whenp
.ID
= 606 then 0 else 1 end,ap
.priority
DESC,p
.post_modified_gmt
DESC
LIMIT 10000, 500
/* 1 = 1 */;Hey @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 –
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 [email protected].
I’m really looking forward to helping you.
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.
Hey @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' );
When will it be released?
We’re looking to release on Feb 27 which is approximately two weeks from now.
- You must be logged in to reply to this topic.