ACSD-47027: slow query B2B CompanyRole GraphQL update

The ACSD-47027 patch solves the issue where the slow query B2B CompanyRole GraphQL update does not work as expected. This patch is available when the Quality Patches Tool (QPT) 1.1.23 is installed. The patch ID is ACSD-47027. Please note that the issue is scheduled to be fixed in Adobe Commerce 2.4.6.

Affected products and versions

The patch is created for Adobe Commerce version:

  • Adobe Commerce (all deployment methods) 2.4.2-p1

Compatible with Adobe Commerce versions:

  • Adobe Commerce (all deployment methods) 2.4.2 - 2.4.5-p1
The patch might become applicable to other versions with new Quality Patches Tool releases. To check if the patch is compatible with your Adobe Commerce version, update the magento/quality-patches package to the latest version and check the compatibility on the Quality Patches Tool: Search for patches page. Use the patch ID as a search keyword to locate the patch.


The slow query B2B CompanyRole GraphQL update does not work as expected.


Install the B2B module.

Steps to reproduce:

  1. In the Adobe Commerce Admin, go to Stores > Settings > Configurations > B2B Features and set Enable Company to Yes.

  2. Go to the frontend and create a company.

  3. After you log in as a company user, go to My Account > Roles and Permissions and add a new role.

  4. Enable dev query log using bin/magento dev:que:enab.

  5. Now send the below GraphQL request (id is the base64 encoded role id):

    code language-none
    mutation {
       input: {
          id: "Mg=="
          permissions: [
     ) {
       role {
      permissions {
      children {
         children {
  6. Check the query log.

  7. You can see that the above query is executed. This query is executed in app/code/Magento/CompanyGraphQl/Model/Company/Role/ValidateRole.php::validateResources.

Expected results:

The app/code/Magento/CompanyGraphQl/Model/Company/Role/ValidateRole.php::validateResources needs to be optimized to avoid loading all the data available in the company_permissions DB table.

Actual results:

Adobe Commerce executes a query without any filter. When there are a large number of records, it takes a lot of time for Adobe Commerce to prepare the data collection.

Apply the patch

To apply individual patches, use the following links depending on your deployment method:

To learn more about Quality Patches Tool, refer to:

For info about other patches available in QPT, refer to Quality Patches Tool: Search for patches in the Quality Patches Tool guide.