Skip to content

#55674: Improve performance Search REST API#2744

Closed
manuelRod wants to merge 15 commits intoWordPress:trunkfrom
xwp:55674-improve-search-api
Closed

#55674: Improve performance Search REST API#2744
manuelRod wants to merge 15 commits intoWordPress:trunkfrom
xwp:55674-improve-search-api

Conversation

@manuelRod
Copy link
Copy Markdown

Trac ticket: #55674


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Copy link
Copy Markdown
Member

@spacedmonkey spacedmonkey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@namithj
Copy link
Copy Markdown

namithj commented May 26, 2022

Why was limiting the fields to ids avoided to fetch the whole post data and then pluck the ids?

@peterwilsoncc
Copy link
Copy Markdown
Contributor

@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.

@manuelRod manuelRod closed this May 30, 2022
@manuelRod manuelRod reopened this May 30, 2022
Copy link
Copy Markdown
Contributor

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thank you!

@spacedmonkey
Copy link
Copy Markdown
Member

Committed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants