#55716 closed enhancement (fixed)
Prime users in cache in WP_Query
Reported by: | spacedmonkey | Owned by: | spacedmonkey |
---|---|---|---|
Milestone: | 6.1 | Priority: | normal |
Severity: | normal | Version: | 1.5 |
Component: | Query | Keywords: | has-patch has-unit-tests has-dev-note |
Focuses: | performance | Cc: |
Description
In WP_Query, when a post is setup using setup_postdata
/ generate_postdata
methods, the function get_userdata
is called. If there are posts that are by multiple authors, this can result in a query per user / author.
The function cache_users
can be called and caches primed for all users in a single request.
Change History (13)
This ticket was mentioned in PR #2722 on WordPress/wordpress-develop by spacedmonkey.
2 years ago
#1
- Keywords has-patch has-unit-tests added
#3
@
2 years ago
I have created a patch for this, including unit tests.
Author data for not need to be primed until we get to loop around posts using the the_post
method. Add a new _prime_user_caches
function to ensure that user meta is correctly primed.
spacedmonkey commented on PR #2722:
2 years ago
#6
Committed
#10
@
2 years ago
- Keywords needs-dev-note added
There are a lot of caching related changes in 6.1 and a dev note should be written collecting them all. Marking this for inclusion.
Trac ticket: https://core.trac.wordpress.org/ticket/55716