Opened 2 years ago
Closed 2 months ago
#57749 closed enhancement (wontfix)
In REST APIs, only prime meta data if there are registered keys
Reported by: | spacedmonkey | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.4 |
Component: | REST API | Keywords: | has-patch has-unit-tests has-testing-info |
Focuses: | rest-api, performance | Cc: |
Description
For REST API controllers like post, term, comment, this use Query classes like WP_Query, WP_Term_Query and WP_Comment_Query under the hood. By default of these query classes, also prime related meta data. This means that when a user requests one of these endpoints, meta data is primed along with the main object. However, this meta data may not be used in anywhere, making this priming unnessary. Meta data should only be primed, if there are registered meta keys that are going to be used.
Change History (8)
This ticket was mentioned in PR #7024 on WordPress/wordpress-develop by @antonvlasenko.
6 months ago
#1
- Keywords has-patch has-unit-tests added
#2
@
6 months ago
- Keywords has-testing-info added
I've submitted a PR that should address the issue described in this Trac ticket.
Steps to test:
- Review the code: Check the changes for correctness and adherence to coding standards.
- Run unit tests: Ensure all GitHub CI test jobs pass successfully.
- Test API endpoints: Make REST API requests to the following endpoints and verify you receive valid responses:
/wp/v2/comments
/wp/v2/posts
/wp/v2/categories
/wp/v2/tags
Since this PR focuses on optimization without introducing new functionality, creating more specific testing steps is challenging.
@antonvlasenko commented on PR #7024:
6 months ago
#3
Are these changes sufficient? Are there other areas that need optimization? If so, this PR can serve as the first step, with follow-up PRs to address additional improvements. Alternatively, I can modify this PR to include more endpoints if necessary.
#4
@
4 months ago
I am aware that I openned this ticket, but I no longer think it is valid. Meta could be used by extra fields added to the rest api. I know I have done this myself. For the reason, we could consider lazily load meta if possible.
#5
@
4 months ago
Thanks for the update, @spacedmonkey.
Would you like to open a new Trac ticket to implement this using lazy loading and close this one?
I'm fine with closing this ticket if it's no longer relevant.
@antonvlasenko commented on PR #7024:
4 months ago
#7
Closing this PR. Reason: https://core.trac.wordpress.org/ticket/57749#comment:4
Trac ticket: https://core.trac.wordpress.org/ticket/57749