Building a WordPress Block Theme: Templates, Styles, and Accessibility
A WordPress block theme lets developers and site owners use blocks to edit every part of a site, including shared areas such…
On a large WordPress site, Yoast SEO generates XML sitemaps that help search engines find eligible pages, products, and other content. Yoast splits those URLs across sitemap files and links the files from a sitemap index. Database queries, work Yoast or another plugin does for each entry, and the server’s time and memory limits can slow a sitemap request.
First find which part of your site is slow. Then decide whether to change a database index or edit Yoast’s code. Issue #12161 documents a real performance problem on a high-volume site, but its proposed query and index changes were disputed and tied to older plugin versions. Treat the issue as a diagnostic case, not a universal fix.
The original report concerned a site with 1.4 million products running Yoast SEO Premium 7.9 or Free 9.5. The reporter said sitemap generation triggered table scans and proposed removing a date condition from a query and adding a database index. An index is a structure that helps a database find and sort rows without examining as many of them.
A Yoast contributor tested a different dataset with 92,000 generated rows. In that test, the query took about 1.290 seconds at offset 0 and 1.340 seconds at offset 90,000. Removing the date condition alone did not improve the result. The original reporter said the query change and index together improved performance on their site. The results show that performance varied between the two environments. They do not establish a diagnosis for every large WordPress site.
The thread does not establish that the historical query still runs in current Yoast versions, that the proposed index helps other databases, or that a later implementation resolved the reported case. Before applying either change, check the query your installed version actually runs and inspect its execution plan, which shows how the database retrieves and sorts the requested rows.
First check whether the delay occurs on the sitemap index or one of its individual sitemap files. Record the WordPress and Yoast SEO versions, along with the PHP and database versions. Note the affected content type and approximate number of entries. Compare the first request with a later one, because a cache can store the sitemap and reduce the work the server repeats.
If the sitemap loads but takes a long time, investigate its performance. If it returns an error or an unexpected URL, check whether Yoast serves that URL and whether another sitemap plugin or a physical sitemap file provides a competing result. Yoast’s sitemap documentation describes the sitemap index and child files.
If measurements show that the database query takes most of the request time, inspect its execution plan in a staging environment or another safe copy of the site. Check whether the database scans or sorts far more rows than the sitemap needs. Add a custom index only when the current query and its plan show that the index addresses the actual bottleneck. An index that does not match the query adds database maintenance work without fixing the slow request.
If the query is not the main cost, measure how much time Yoast and other plugins spend on each sitemap entry. A separate report describes get_sitemap_links consuming substantial time on requests that the reporter believed did not need it; that report concerns another issue and does not diagnose #12161. A commenter on #12161 also attributed a slow sitemap to a theme processing shortcodes while Yoast extracted images. These reports make per-entry work worth checking, but neither establishes a cause for other sites.
Yoast provides the wpseo_sitemap_entries_per_page filter, a named point where custom code can set how many entries appear in each sitemap file. Test a smaller and a larger value while measuring response time and confirming that every file remains valid. Smaller files reduce the work for an individual response but create more files. Larger files reduce the number of files but make each response handle more entries.
Yoast’s documentation includes an example value, while another help page describes a default of 1,000 entries. Because the published pages do not give a consistent default, check the behavior of your installed version rather than assuming one value applies everywhere. The high-volume site support discussion also recommends testing entry counts, but it does not provide a controlled benchmark that establishes an ideal size.
Review which post types and taxonomies belong in search results. Excluding content that should not be indexed reduces the URLs Yoast must include. Keep pages that search engines should discover; exclusions should reflect the site’s indexing decisions, not serve as a shortcut for hiding performance problems.
A sitemap request can fail when PHP reaches its execution-time limit or runs out of memory, even if the database query is acceptable. Check the PHP error log and the configured max_execution_time and memory_limit when requests time out or return errors. A WordPress.org support reply recommends checking these limits alongside sitemap size and content volume, but it does not show that changing either setting fixes the query reported in #12161.
Caching can reduce repeated generation work. Yoast documents transient caching, which stores a generated sitemap for reuse, and notes that WordPress, server, or CDN caches can affect when sitemap changes appear. Measure both the response time and whether updated URLs become visible when expected. A cache can make repeated requests faster while leaving an inefficient query unchanged.
Do not copy the index proposal from the 2019 issue or remove a query condition from current plugin code without confirming that your installation runs the same query and benefits from the change. The date condition may affect which content the query returns, and a custom index must match the live query to help. Test changes on staging against the site’s content, sitemap output, and custom integrations, then keep a rollback plan.
Direct edits to Yoast’s plugin files also risk being overwritten by an update. If profiling supports a code-level change, use a supported extension point where one exists and verify that the change preserves sitemap entries added by other plugins or custom code. The issue’s later discussion of index-based sitemap work does not establish which current release includes that work, so check the installed version’s behavior rather than relying on the proposal.
Give Vroni a GitHub issue, bug report, spec, or rough idea. It reads the repo, plans the change, writes code, runs checks, and works toward a review-ready pull request.
Take a look at vroni.com