If you are using Magento 2 Commerce / Adobe Commerce and make use of the Gift Card feature, there is a simple fix that can speed up the use of gift cards in the cart (both checking the balance and applying them).
The database for gift cards, specifically the table magento_giftcardaccount, is missing a crucial index that can cause very slow gift card usage if your store has a lot of gift cards.
The column โCodeโ, which is the gift card redemption code, does not have an index on it. There are queries that run when a customer checks the card balance, or attempts to apply the card in the cart of the format:
SELECT COUNT(*) FROM `magento_giftcardaccount` AS `main_table` WHERE ((`code` = ‘XYZ’))
ย
SELECT `main_table`.* FROM `magento_giftcardaccount` AS `main_table` WHERE ((`code` = ‘XYZ’)) LIMIT 1
Without an index, a full table scan must be performed for these 2 queries. If your store has thousands (or millions) of gift cards, these queries can take 3-5 seconds per query, which results in a delay of 6-10 seconds in the cart when the customer tries to use a gift card!
Adding a simple index to this column (or even a UNIQUE index as no 2 codes should be the same) will make these queries complete almost instantly. This means when a customer enters a gift card in the cart, the result is immediate, which is a win for usability!
We added an index to Code for one client who makes extensive use of gift cards, and dropped the time in the cart when applying a gift card from 8 seconds to 0.004 seconds.
A simple fix to drastically speed up the gift card feature in Magento 2 Commerce edition.
ย
โTweet If you are using Magento 2 Commerce / Adobe Commerce and make use of the Gift Card feature, there is a simple fix that can speed up the use of gift cards in the cart (both checking the balance and applying them). The database for gift cards, specifically the table magento_giftcardaccount, is missing a
Related posts:
New Mastercard and Discover Rules Concerning Debit, Pre-paid and Gift Cards
Magento โ Faster Than a Speeding Bullet
How to use a PHP profiler to audit a slow Adobe Commerce siteย ย