Repository navigation
[6.x] Find which entries are published once when building the entries_count index - #15898
Open
DanielDarrenJones wants to merge 2 commits into
Open
DanielDarrenJones wants to merge 2 commits into
DanielDarrenJones wants to merge 2 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
entries_countterm index (used when terms are filtered or sorted by it, such asmin_counton the taxonomy tag) is built by asking for each term's published entries one term at a time. Each of those is a query over every entry, so the build grows with terms × entries.This finds which of the associated entries are published with one query, then counts each term from the associations the index already reads.
On a generated site of 11,771 entries and 2,446 terms (6.42.0, CPU time, two runs each):
The index values are identical before and after (compared serialized, all three taxonomies).
Where this build happens during a request rather than a warm, that request is the one waiting for it.
Kept as they were:
Term::entriesCount().entriesCount()is still asked for each term.The new test counts entry queries while the index is built: 11 before, 1 after.
Found by @godismyjudge95, who measured this on a much larger site and shared the approach.