Skip to content

Using QuoteIdToMaskedQuoteId shouldn't increase response time #33676

Closed
@ihor-sviziev

Description

@ihor-sviziev

In the Klaviyo extension, we have a plugin that adds a masked quote id to quote search API requests. That looks like quite a small plugin that shouldn't cause any performance damage. But, by just commenting fetching masked quote ID - I noticed that performance is improved more than 2 times.

Here is a link to the plugin in Klaviyo extension (it uses API class, which is ok):
https://github.com/klaviyo/magento2-klaviyo/blob/3.0.5/Plugin/Api/CartSearchRepository.php

Detailed investigation shown that issue is coming from the following line:

public function execute(int $quoteId): string
{
/* Check the quote exists to avoid database constraint issues */
$this->cartRepository->get($quoteId);

Basically, that code fetches again all the quotes again, and all their quote items and so on just for... checking if such quote exists!

Preconditions (*)

  1. Magento 2.3.7 or 2.4-develop

Steps to reproduce (*)

  1. Install Klaviyo extension (tested on version 3.0.5)
  2. Create at least 20 quotes
  3. Run the following code with and w/o Klaviyo extension:
curl --location --request GET 'https://www.mymagento.com/index.php/rest/default/V1/carts/search?searchCriteria%5Bfilter_groups%5D%5B0%5D%5Bfilters%5D%5B0%5D%5Bfield%5D=updated_at&searchCriteria%5Bfilter_groups%5D%5B0%5D%5Bfilters%5D%5B0%5D%5Bvalue%5D=2021-06-11+11%3A38%3A16&searchCriteria%5Bfilter_groups%5D%5B0%5D%5Bfilters%5D%5B0%5D%5Bcondition_type%5D=gt&searchCriteria%5BsortOrders%5D%5B0%5D%5Bfield%5D=updated_at&searchCriteria%5BsortOrders%5D%5B0%5D%5Bdirection%5D=DESC&searchCriteria%5BcurrentPage%5D=1&searchCriteria%5BpageSize%5D=50' \
--header 'Authorization: Bearer dk6zp483qmck8omd7sov1r3b9is7kxh'

Note: here is documentation on how to get access token https://devdocs.magento.com/guides/v2.4/get-started/authentication/gs-authentication-token.html#request-token

Expected result (*)

  1. You should see approximately the same response time

Actual result (*)

  1. Response time slowed down at least 30% with an enabled module.

Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • 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

Assignees

Labels

Fixed in 2.4.xThe issue has been fixed in 2.4-develop branchIssue: ready for confirmationPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: doneSeverity: S1Affects critical data or functionality and forces users to employ a workaround.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions