Skip to content

paypal/module-braintree-core has huge performance hit on sales order grid #40340

@mlaurense

Description

@mlaurense

Preconditions and environment

  • Magento version: 2.4.7-p8
  • Have 1 million+ orders in your sales grid

Steps to reproduce

In vendor/paypal/module-braintree-core/Plugin/SalesOrderGridPlugin.php two joins are added to select additional fields for the Sales Order grid. This results in roughly this query being run on the database:

SELECT `main_table`.*, `braintree_transaction_details`.`transaction_source` FROM `sales_order_grid` AS `main_table`
 LEFT JOIN `braintree_transaction_details` ON braintree_transaction_details.order_id = main_table.entity_id
 LEFT JOIN `sales_order` ON sales_order.entity_id = main_table.entity_id ORDER BY main_table.created_at DESC
 LIMIT 10

(LIMIT 10 added to not let my DB client die).
This query takes ~ 6.5 seconds on my test environment.

Removing the JOIN improves loading hugely:

SELECT `main_table`.* FROM `sales_order_grid` AS `main_table`
LEFT JOIN `sales_order` ON sales_order.entity_id = main_table.entity_id ORDER BY main_table.created_at DESC
 LIMIT 10

Query now runs in ~ 20ms.

Expected result

Order grid should load in less than 2 seconds.

Actual result

Order grid is terribly slow.

Additional information

No response

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Type

No type

Projects

Status

Ready for Confirmation

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions