[Enhancement]: reduce calls to wp_count_posts( 'product' )
from OnboardingTasks
#43768
Labels
focus: performance
The issue/PR is related to performance.
focus: setup checklist
Issue related to onboarding task list.
team: Ghidorah
type: enhancement
The issue is a request for an enhancement.
Describe the solution you'd like
I was looking at #36652, which complained we are calling
wp_count_posts( 'product' )
on each admin request. That particular issue was specifically interested in the call stemming from someWC_Install
code, but there are other sources too, one of which is the following chain:Automattic\WooCommerce\Admin\Features\OnboardingTasks\TaskLists::menu_task_count()
Automattic\WooCommerce\Admin\Features\OnboardingTasks\TaskLists::setup_tasks_remaining()
Automattic\WooCommerce\Admin\Features\OnboardingTasks\TaskList::is_complete()
Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks\Products::is_complete()
Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks\Products::has_products()
wp_count_posts()
I wonder if this (the number of requests in which we need to call
wp_count_posts()
) could be reduced via transient caching or similar? Post counts are already cached by WP, but only on a per-request basis (unless persistent object caching is present).Describe alternatives you've considered
Instead of using transient based caching, perhaps other heuristics are available? Mostly wanted to flag since it's a complaint that's cropped up in other contexts, too, like #31029 (which complains about essentially the same thing, but via WC Tracker).
Additional context
I wonder if it would make sense to address in tandem with #36195?
The text was updated successfully, but these errors were encountered: