Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve slow query for legacy subscriptions on WC status tools page by caching the data #3848

Merged
merged 3 commits into from
Feb 7, 2025

Conversation

Mayisha
Copy link
Contributor

@Mayisha Mayisha commented Feb 6, 2025

Fixes #3755

Changes proposed in this Pull Request:

To avoid frequent unnecessary DB calls on WooCommerce > Status > Tools page, we are caching the number of subscriptions having the legacy Stripe Sepa as the payment method.

This is not an issue for the sites with a small number of orders/subscriptions but it will improve performance for the sites having a large number of orders. The site used in #3755 has ~1 million orders and this query takes ~2 sec each time.

Testing instructions

  • Enable the subscriptions plugin.
  • Create subscription products and purchase a few subscriptions as a shopper if you already don't have any.
  • Go to WooCommerce > Status > Tools page and open the query monitor.
  • As you don't have the cached data by this time, you should see the following DB query.
Screenshot 2025-02-06 at 1 06 23 PM
  • Now refresh the page and confirm that the above DB query is not executed this time.
  • Check your DB and confirm that you have the woocommerce_stripe_subscriptions_with_legacy_sepa transient set.

@Mayisha Mayisha requested review from a team and diegocurbelo and removed request for a team February 6, 2025 07:12
Copy link
Member

@diegocurbelo diegocurbelo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚢

Copy link
Member

@diegocurbelo diegocurbelo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚢

@Mayisha Mayisha merged commit 53e7591 into develop Feb 7, 2025
37 checks passed
@Mayisha Mayisha deleted the tweak/3755-legacy-sepa-performance branch February 7, 2025 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Performance]: Slow query for legacy subscriptions on WC status tools page
2 participants