WordPress is due to release version 6.4 on the 7th of November 2023. In this release, the performance team has introduced several enhancements focussed on object caching, leading to better handling of filters, reduced database queries, and improved overall system efficiency.
These updates include a number of refined caching features and fixes across the WordPress system. Especially interesting are the two for the most common methods of custom queries to the database with
Forcing split queries when object caching is enabled
While split queries have been available since version 3.1, they were optional, and were restricted to a maximum of 500 posts. With these latest updates, these restrictions have been eliminated when persistent/external object caching is enabled. This enhancement becomes even more significant with the introduction of
wp_cache_get_multiple() in WordPress core. With this function, object caches can retrieve multiple objects in a single request, offering several benefits.
The benefits of Split Queries and Object Caching
Performance Improvement: Object caches, which store frequently accessed data in memory, are substantially faster than traditional database queries. By using split queries, WordPress can fetch post IDs more efficiently, reducing the load time for your website.
Database Offloading: The implementation of split queries alleviates the strain on the database. With only the essential post IDs selected, less data needs to be retrieved from the database, and fewer database queries are executed.
Primary Key Loading: The primary key for loading the post object is the focus, ensuring that the necessary data is efficiently fetched from the object cache.
New cache_results parameter in
cache_results parameter has been introduced in WordPress to provide developers with more control over the caching behaviour in
WP_Term_Query queries. It allows you to determine whether or not to load results from the query cache, enabling you to obtain a complete uncached result when set to false.
Where applicable, it is always beneficial to load content from the cache to avoid as many full database queries as possible. That way, you can improve the performance of your WordPress site as dynamic pages can hit the cache instead of running a full database query while creating the page. With this addition to the term queries, developers can ensure even more of the content can use a cache where applicable.
How to use the new
$args = array( 'taxonomy' => 'category', 'cache_results' => true, // This will fetch cached results ); $term_query = new WP_Term_Query($args);
It is great to see the performance team adding new features and tweaking current ones to ensure WordPress-powered websites perform at their best.
These are just a couple of the updates made by the performance team ready for WordPress version 6.4. For more information on these and other updates included in the next version, see the Make WordPress Core website.