Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PERF] ConvertLegacyStoredDataObserver expensive query on sales_order table for ext_customer_id in (NULL) #13

Closed
steven-hoffman-jomashop opened this issue Nov 19, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@steven-hoffman-jomashop

https://github.com/ParadoxLabs-Inc/authnetcim/blob/master/Observer/ConvertLegacyStoredDataObserver.php

🐢 Performance Issue

Current behavior

When ConvertLegacyStoredDataObserver triggers it can make a query like the following.
SELECT `main_table`.* FROM `sales_order` AS `main_table` WHERE (`ext_customer_id` IN(NULL))
This is clearly very expensive; in any case, unnecessary.

Expected behavior

Not make the query when the condition is NULL.
(Note this would be expensive if the condition is not null)

Minimal reproduction of the problem with instructions

  • Trigger ConvertLegacyStoredDataObserver::execute
  • Ensure that you react $cards = $this->getCardsFromProfile($profile);
  • Ensure that $cards = $this->getCardsFromProfile($profile); is not empty
  • Ensure that $this->convertCards unsets the cards
  • Update orders is fired with an empty array (Leading to the null above)

What is the motivation / use case for changing the behavior?

  • Increase performance in the simple case

Environment

  • Should replicate in 5.1.2 as relevant code appears unchanged
  • (It does seem that converting guests to customer is contributing as Car.php sets version 200, but customer may be a guest at that point)
@rhoerr
Copy link
Member

rhoerr commented Nov 19, 2024

Thanks @steven-hoffman-jomashop ! This should be fairly easy for us to check and fix. We'll short-circuit updateOrders() if $cards is empty.

@rhoerr rhoerr added the bug Something isn't working label Nov 19, 2024
@rhoerr rhoerr closed this as completed in 5d4930c Dec 23, 2024
@rhoerr
Copy link
Member

rhoerr commented Dec 23, 2024

Pushed a change that should resolve this. Will be included in our next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants