#55674 closed enhancement (fixed)
Improve performance Search REST API
Reported by: | furi3r | Owned by: | spacedmonkey |
---|---|---|---|
Milestone: | 6.1 | Priority: | normal |
Severity: | normal | Version: | 5.0 |
Component: | REST API | Keywords: | has-patch has-unit-tests commit early assigned-for-commit has-dev-note |
Focuses: | performance | Cc: |
Description
Search query rest endpoint will make a query per post_id for each post in the result.
A possible solution, Prime_post_cache needed.
https://github.com/WordPress/wordpress-develop/blob/4558de543c64c877ffea4cdfbdf67d743c3e4391/src/wp-includes/rest-api/search/class-wp-rest-post-search-handler.php#L86
Attachments (3)
Change History (23)
This ticket was mentioned in PR #2744 on WordPress/wordpress-develop by manuelRod.
2 years ago
#2
- Keywords has-patch has-unit-tests added
Trac ticket: #55674
#3
@
2 years ago
- Keywords commit early added
- Milestone changed from Awaiting Review to 6.1
- Owner set to spacedmonkey
- Status changed from new to assigned
- Version set to 4.7
This ticket was mentioned in Slack in #core by costdev. View the logs.
2 years ago
2 years ago
#5
Why was limiting the fields to ids avoided to fetch the whole post data and then pluck the ids?
peterwilsoncc commented on PR #2744:
2 years ago
#6
@namithj
Why was limiting the fields to ids avoided to fetch the whole post data and then pluck the ids?
Doing a query for the entire post object will warm the object cache for the get_post()
function calls in the prepare_item()
method. This prevents an additional database query for each found post.
You raise a good point though, it's probably worth adding a comment explaining this in the code so a future developer doesn't change the query and cause extra database queries.
#7
@
2 years ago
See attachment, before and after applying the patch, we save one query per result, and the time is considerably reduced.
For a 6 items result:
27 VS 22 queries.
0.0171s VS 0.0146s
This ticket was mentioned in Slack in #core by chaion07. View the logs.
2 years ago
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
2 years ago
#11
@
2 years ago
- Keywords assigned-for-commit added
- Owner changed from spacedmonkey to audrasjb
- Status changed from assigned to accepted
#12
@
2 years ago
@audrasjb Are you good to commit this. It as been approved by two core committers ( me included ).
#13
@
2 years ago
- Owner changed from audrasjb to spacedmonkey
- Status changed from accepted to assigned
Reassigned to @spacedmonkey who is taking care of this ticket from the beginning :)
spacedmonkey commented on PR #2744:
2 years ago
#15
Committed.
#17
@
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.
api query result