This repository was archived by the owner on May 21, 2025. It is now read-only.
Issue/4795 prevent related order duplicate queries on subscriptions list table #788
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.
Fixes https://github.com/woocommerce/woocommerce-subscriptions/issues/4795
Description
This PR reduces the number of duplicate queries running on the WooCommerce → Subscriptions list table, decreasing them from 137 to 60. This PR focuses on two key functions:
1. Optimizing
get_date_column_content()
get_time()
multiple times. When rendering the Last Order Date column, each call triggered aget_related_orders()
query, resulting in redundant database reads.get_time()
calls when generating date columns.2. Improving
WC_Subscription::get_related_orders()
get_related_orders()
was called with multiple order types, it triggered separateget_related_order_ids()
queries for each type.WCS_Related_Order_Store::instance()->get_related_order_ids()
for each type and therefore a full read from the subscription meta table.Example:
Summary of Changes
get_time()
calls inget_date_column_content()
.WC_Subscription::get_related_order_ids()
andWCS_Related_Order_Store
to allow fetching multiple related orders caches with a single database read.How to test this PR
get_related_order_metadata()
137 duplicate queries.
Product impact