-
Notifications
You must be signed in to change notification settings - Fork 175
Description
What happened?
Description:
I am experiencing a performance degradation in the Control Panel due to duplicated queries related to Subscription Plans.
Even though I am not actively using Subscriptions ), the system runs the exact same query for commerce_plans multiple times (10+) on every single page load of the Control Panel. It appears that the result of this query is not being memoized/cached during the request, causing it to run repeatedly—likely once for every item in the Sidebar navigation.
Steps to reproduce:
Enable the Debug Toolbar (or look at web.log profiling).
Load any page in the Control Panel (e.g., the Dashboard or Entries index).
Inspect the Database Queries.
Observe that the following query is repeated multiple times (identical execution):
SQL
SELECT p.dateArchived, p.dateCreated, p.dateUpdated, p.enabled, p.gatewayId, p.handle, p.id, p.isArchived, p.name, p.planData, p.planInformationId, p.reference, p.sortOrder, p.uid
FROM commerce_plans p
LEFT JOIN commerce_gateways g ON g.id = p.gatewayId
WHERE g.isArchived=FALSE
ORDER BY sortOrder
Additional info:
Impact: This results in 10-20 extra database queries per page load, contributing to slower CP load times, especially on sites with complex navigation or many plugins hooking into the sidebar.
Craft CMS version
5.8.20
Craft Commerce version
5.5.0
PHP version
8.3
Operating system and version
Windows 11
Database type and version
MySQL
Image driver and version
No response