Opened 2 years ago
Last modified 5 months ago
#57416 assigned enhancement
Do not split query if requesting one post
Reported by: | spacedmonkey | Owned by: | spacedmonkey |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | 3.0 |
Component: | Query | Keywords: | good-first-bug has-patch dev-feedback needs-testing has-unit-tests |
Focuses: | performance | Cc: |
Description
When using WP_Query and requesting posts_per_page = 1, there is little to no value in splitting the query and priming posts using _prime_post_caches. This results in one query to get the posts and another to prime it. This means two database queries when this could simply be one.
Attachments (2)
Change History (9)
#2
@
18 months ago
- Keywords has-patch dev-feedback needs-testing added; needs-patch removed
The patch simply checks query field 'posts_per_page' equals to 1 and sets split flag to false in this case and skips other filtering whether to split.
@
13 months ago
Add a condition to split_the_query for whether the call is for a single post and add unit tests.
#5
@
13 months ago
I refreshed the patch, but also changed the implementation a little from the original, in that it doesn't skip over the filter. Also added unit tests.
This ticket was mentioned in PR #7025 on WordPress/wordpress-develop by locol-media-dev.
5 months ago
#7
- Keywords has-unit-tests added; needs-unit-tests removed
Patch checks for post per page == 1 before splitting the query