Current Orders Cache Query implementation results in more queries than when disabled. #45550
Open
5 tasks done
Labels
focus: data-store
Issues related to custom tables.
focus: order
Issues related to orders.
focus: performance
The issue/PR is related to performance.
priority: normal
The issue/PR is of normal priority—not many people are affected or there’s a workaround, etc.
team: Proton
WC Core development and maintenance
type: enhancement
The issue is a request for an enhancement.
Prerequisites
Describe the bug
Querying a set of orders with
orders_cache_usage_is_enabled() === true
results in more queries than when it is disabled when querying a set of orders by ID.Because the
WC_Data::__sleep()
method only stores the ID, theWC_Data::__wakeup()
method is set to run the initial object constructor again. For orders, this results in two queries being run for each order requested - one for the order data and one for meta.When caching is disabled, the data for the set of orders and meta can be retrieved for all orders in two queries.
Expected behavior
The expectation behind cached orders is that a successful cache hit of an order would not result in a DB read being made.
Actual behavior
A successful cache hit for an order requires two DB reads because only the ID is stored in cache.
Steps to reproduce
1, Setup an environment with multiple orders and note the IDs.
2. Disabled the
orders_cache_usage_is_enabled
feature flag.3. Setup a script to test the number of queries run, e.g.:
orders_cache_usage_is_enabled
feature flag.WordPress Environment
WPCOM
Isolating the problem
The text was updated successfully, but these errors were encountered: