Uh oh!
There was an error while loading. Please reload this page.
[6.x] Fix performance issue when duplicating entries in large collections - #14995
Merged
Conversation
The slug uniqueness check queried by `locale`, which isn't a registered Stache index for entries. On first use it required hydrating every entry file in the collection across all sites to build an ad-hoc index, causing timeouts on large collections. Querying by `site` instead reuses the index that's already warmed by normal CP traffic (e.g. collection listings).
Uh oh!
There was an error while loading. Please reload this page.
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 freeto 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.
This pull request fixes an issue where duplicating an entry in a large collection (especially multisite, with many entries per site) could result in a 504 Gateway Timeout.
This was happening because the slug uniqueness check in
DuplicateEntry::generateTitleAndSlug()queried entries bylocale, which isn't a registered Stache index. Since nothing else in the codebase queries entries bylocale, that index was never warmed, so the first time it was needed it had to hydrate every entry file in the collection (across all sites) from disk just to build it.This PR fixes it by querying by
siteinstead, which holds the same values but is already a registered Stache index that's warmed by normal Control Panel usage (like viewing a collection's entry listing), making the check effectively instant in practice.Fixes#14992