One of the WordPress core committers, Jonny Harris, has merged a patch for a 12-year-old ticket that was remaining unpatched. The ticket is about the unnecessary queries for custom pages without WordPress post content and it is now closed.
Getting rid of unnecessary queries
The refreshed patch for the 12-year-old issue was developed by the contributor Paul Bearne. The patch adds boolean returns to parse_request(), adds a shortcut to stop loading unnecessary calls to main()if parse_request returns early, and adds a test to make sure parse_request() returns boolean.
Plugins such as Google’s Site Kit, Events Calendar, and AMP uses this filter. Jonny Harris summarizes the problem and the fix by following words:
« Developers of plugins and themes can use the do_parse_request filter to hot-wire requests and hook in early to render custom pages. However, even though these requests may not need post queries and 404 lookups to be run, they run anyway. This can result in unnecessary SQL queries running on these requests. By adding a return value to the parse_request method of the WP class, these queries can now be skipped. »
According to Harris, this fix should bring significant performance uplift for custom pages. Currently, the fix seems not to be bugging any of the tested plugins. But the developers are cautious about unnoticed side effects. They have quite a lot of time to test it until the release of WordPress 6.0, which is scheduled for the end of May 2022.