#55360 closed enhancement (fixed)
Add limit to query in WP_Tax_Query
Reported by: | spacedmonkey | Owned by: | spacedmonkey |
---|---|---|---|
Milestone: | 6.0 | Priority: | normal |
Severity: | normal | Version: | 4.7 |
Component: | Taxonomy | Keywords: | has-patch has-unit-tests commit has-dev-note |
Focuses: | performance | Cc: |
Description
The call to get_terms in WP_Tax_Query, does not currently have a limit set. This because some taxonomies are hierarchical and could have nested terms. But for none hierarchical taxonomies, a limit can and should be set. This limit will improve query performance and will improve likely of hitting an existing term query cache.
Attachments (2)
Change History (10)
This ticket was mentioned in PR #2396 on WordPress/wordpress-develop by spacedmonkey.
3 years ago
#1
- Keywords has-patch added
#2
@
2 years ago
- Keywords has-unit-tests added
I recommend testing this ticket along side #55352.
With this change in place, it means that the early call to get_term_by
populates the cache for the taxonomy query. This means one less query per page on tag pages.
Even without this benefit, limiting the query, makes the query return first, as SQL, stop processing once the limit is meet.
#4
@
2 years ago
- Keywords commit added
Linked pull request approved, @spacedmonkey are you able to take the honors for commit?
spacedmonkey commented on PR #2396:
2 years ago
#6
Merged into core.
Trac ticket: https://core.trac.wordpress.org/ticket/55360