Improve performance rendering the Last Order Date column value on the WooCommerce > Subscriptions list table #782
Labels
category: performance
The issue/PR is related to performance.
needs prioritisation
Issue needs a priority label set (or existing priority label reviewed).
woocommerce-subscriptions-core
Description
On the WooCommerce > Subscriptions list table, we display a column for each Subscription's last order date:
Each date value displayed in the Last Order Date column is calculated by:
date_created
valueNeeding to calculate this value for every subscription rendered on the WooCommerce > Subscriptions page adds unnecessary performance burden, not to mention the queries required to sort by this column as well.
Possible Solutions
This is not an ideal solution, but more of a temporary short-term fix.
In Subscriptions we have a helper function (see
wcs_is_large_site()
) that categorises large sites as those with 3,000+ subscriptions. To increase the performance of this page, we could prevent this column from being loaded/calculated on large subscription stores. If stores want it back, we could add a filter to include it.Important
Sorting by this column allows merchants to find the most recently renewed subscriptions, so it might introduce a bad experience to merchants if we just remove this column entirely.
last_order_date
as metadata on the subscription.For our other date fields (i.e. next payment, trial end, end date etc), even though these dates are already calculated and stored in Action Scheduler as pending scheduled actions, we also store these values as metadata on the subscription and keep these values in sync.
The idea of this solution would be to calculate and store this value in metadata and then as part of our related orders handling, we could keep this value in sync.
Storing this value as metadata would reduce the need to fetch and instantiate the last order, but also improve our queries that sort the table by last order date.
The text was updated successfully, but these errors were encountered: