fix: return only unique Author ID <=> Post Author (ID) pairings.#22065
Merged
pls78 merged 1 commit intoYoast:trunkfrom Apr 4, 2025
Merged
fix: return only unique Author ID <=> Post Author (ID) pairings.#22065pls78 merged 1 commit intoYoast:trunkfrom
pls78 merged 1 commit intoYoast:trunkfrom
Conversation
Because of the join across the `wp_posts` table, there could potentially be _many_ posts where an author has been updated. Currently, each of those rows are returned but that data is discarded because the `SELECT` statement only grabs `author_id` <=> `post_author` pairings. For large data sets, this leads to an extremely inflated data list of duplicated `author_id` <=> `post_author` (ID) pairings. With the `GROUP BY` statement, we ensure that only unique `author_id` <=> `post_author` (ID) pairings are returned, leading to much more efficient operation (from a code standpoint).
Member
|
Hey @eddiesshop, thanks for the suggestion! We'll try to schedule a review and test in the upcoming weeks (we can't commit to a date since we are currently working on a large project). |
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.
Because of the join across the
wp_poststable, there could potentially be many posts where an author has been updated. Currently, each of those rows are returned but that data is discarded because theSELECTstatement only grabsauthor_id<=>post_authorpairings. For large data sets, this leads to an extremely inflated data list of duplicatedauthor_id<=>post_author(ID) pairings.With the
GROUP BYstatement, we ensure that only uniqueauthor_id<=>post_author(ID) pairings are returned, leading to much more efficient operation (from a code standpoint).Context
See this issue: #22064
This PR makes the
update_indexables_author_to_reassignedoperation, and thewp yoast cleanupoperation, much more efficient, by tackling only the (Old) Author ID <=> (New) Post Author (ID) pairings that need to be processed.Summary
This PR can be summarized in the following changelog entry:
changelog: enhancement
wp yoast cleanupCLI command would hang when it reaches theupdate_indexables_author_to_reassignedstep (for very large data sets). Props to eddiesshop.Relevant technical choices:
Test instructions
Test instructions for the acceptance test before the PR gets merged
This PR can be acceptance tested by following these steps:
wp yoast indexwp yoast cleanup. Notice that the command hangs at theupdate_indexables_author_to_reassignedstep.SELECT wp_yoast_indexable.author_id, wp_posts.post_author FROM wp_yoast_indexable JOIN wp_posts on wp_yoast_indexable.object_id = wp_posts.id WHERE object_type='post' AND wp_yoast_indexable.author_id <> wp_posts.post_author ORDER BY wp_yoast_indexable.author_id. Notice that this query returns the same number of rows as the posts that you created.SELECT wp_yoast_indexable.author_id, wp_posts.post_author FROM wp_yoast_indexable JOIN wp_posts on wp_yoast_indexable.object_id = wp_posts.id WHERE object_type='post' AND wp_yoast_indexable.author_id <> wp_posts.post_author GROUP BY wp_yoast_indexable.author_id, wp_posts.post_author ORDER BY wp_yoast_indexable.author_id. Notice that only 1 row is returned, indicating the Old Author ID being updated with the New Post Author ID.wp yoast cleanup. Notice that the command runs without hanging.Relevant test scenarios
Please see test steps above for reasoning on selecting second choice.
Test instructions for QA when the code is in the RC
N/A
QA can test this PR by following these steps:
N/A
Impact check
This PR affects the following parts of the plugin, which may require extra testing:
N/A
UI changes
Other environments
[shopify-seo], added test instructions for Shopify and attached theShopifylabel to this PR.Documentation
Quality assurance
Innovation
innovationlabel.Fixes #22064