WordPress 6.1, slated for November 2022, will bring “significant database performance improvements” thanks to new post-query caching.
This new feature will improve the performance of your WordPress website.
The precision caching improvements are to post-query caching.
In a Twitter thread announcing, someone asked if this improvement had already started in version 6.0.
According to the major WordPress contributors who worked on this project, the caching feature brings dramatic improvements.
Main contributor murmured:
“WordPress 6.1 has significantly improved database performance.
WP_Query database queries are now cached. A ticket that has been worked on for over 5 years has been merged.
This should save billions of repeated database queries. ”
A draft development note has also been started with more information about caching.
“WordPress 6.1 has an improved way to perform database queries in the ‘WP_Query’ class, caching the results of database queries in the object cache.
This means that if the same database query is executed multiple times, the results will be read from cache.
If you’re using persistent object caching, this means that database queries won’t run again until the cache is invalidated, and queries to the database are rarely run. ”
“Thanks! Isn’t this already fixed in 6.0?
This caused big problems for big woo-stores. If only the child categories are checked and not the top level (parent) categories, the archive page categories will disappear.
I’m interested in notes with more context.”
WordPress core committer responded:
“We are constantly improving database performance.
6.0 improved term query caching. This is post query caching. Related but not the same.
This issue has been fixed in 6.0.1. I patched it myself. ”
WordPress database and queries
WordPress stores different parts of your website in a database.
The database contains information about sites organized in tables.
For example, all the content of a web page post is stored in a table.
When someone visits a web page, WordPress “queries” the database to find and find the content of that web page in the database.
WordPress makes multiple queries to the database for each web page requested and runs them for every site visitor.
As a result, thousands of occurrences per minute can overwhelm the server, resulting in poor database performance and slowing down the entire site.
With this new database caching feature, instead of making a database query, we first check to see if what we’re looking for is in the cache and retrieve the information from there.
This is similar to ordering lunch. Instead of waiting for your lunch to be made, the order taker reaches under the counter and makes it right away.
Response from the WordPress community
The informal announcement was received with enthusiasm.
Congratulations. such a big impact.
— Ellie Sloim (@ElieSl) September 27, 2022
Fairplay, this is huge in many ways. Can’t wait to try this. Thank you for your hard work and persistence!
— Simon Pollard (@smp303) September 27, 2022
Good for you, Johnny! It’s pretty cool to be able to have a positive impact on that scale.
— Keith Devon (@keithdevon) September 27, 2022
Great! It always bugged me that I had to jump through hoops to avoid duplicate queries with this.
— John Brown (@jb510) September 27, 2022
Fix last minute issue
Despite enthusiastic tweets announcing that this feature will be included in the next WordPress release, a final issue has arisen that seems to cast doubt on whether this feature will be included in the next WordPress release. .
The GitHub ticket for the cache project has been closed. So it looks like all the bugs have been resolved and the project is closed.
However, a few hours later, the same WordPress contributor reopened the ticket as a new issue was discovered.
The issue discovered had to do with persistent object caching.
They wrote an explanation:
“We found some issues with persistent object caching, so we’re reopening.
Issue 1 – If persistent object caching is enabled, add cache is called too often. This is because update_post_caches is called. Do not call this function if the object cache is enabled.
Issue 2 – Cache set is called every time WP_Query is executed, not just the first time. ”
A new GitHub pull release has been opened to document fixes for newly discovered issues.
Confirmed: Database Cache Included in WordPress 6.1
I reached out to the developer via Twitter direct message and they said there was no delay.
He confirmed that with six weeks left as of today, these newly discovered issues will be fixed and the new caching feature will be included in WordPress 6.1.
A few days later we were informed that the GitHub pull release for this feature was updated and the issue was resolved.
The comment said:
“Query: Store excess cache additions and settings in WP_Query.
of  Added database query caching to WP_Query. However, for sites with persistent object caching enabled, this resulted in a large number of unnecessary cache sets, appending on every request. If the query cache already exists and is cached, the cache will not be set. Replace use of update_post_caches with _prime_post_caches so that only non-cached posts are primed. ”
Then, shortly after that comment, the main contributor said:
- fixed resolution
- Status changed from reopened to closed
Nothing has been officially announced yet, but that’s not unusual. Every release contains hundreds of improvements, with the most important ones usually highlighted on the actual release date.
New features to improve WordPress performance are coming to version 6.1, currently scheduled for November 2022.
Featured image from Shutterstock/iViDI Studio