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

Magento EAV query performance issue on the product view page #39554

Open
5 tasks
onlinebizsoft opened this issue Jan 20, 2025 · 1 comment
Open
5 tasks

Magento EAV query performance issue on the product view page #39554

onlinebizsoft opened this issue Jan 20, 2025 · 1 comment
Labels
Reported on 2.4.x Indicates original Magento version for the Issue report. Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it

Comments

@onlinebizsoft
Copy link

Summary

On the product view, we have SQL to load the product attribute information from EAV tables which looks like below one

SELECT u.* FROM ( (SELECT t.value, t.attribute_id, t.store_id FROM ..........UNION ALL(SELECT t.value, t.attribute_id, t.store_id FROM ........UNION ALL(SELECT t.value, t.attribute_id, t.store_id FROM .................. AND (attribute_id IN (87, 62, 88, 63, 77, 78, 1387, 1388, 966)) AND (store_id IN (6, 0))) ) AS u ORDER BY store_id ASC

This is a top query in the system which contribute to the database CPU usage. It likely happens on a system with MANY different products so caching was not very effective.

Examples

SELECT u.* FROM ( (SELECT t.value, t.attribute_id, t.store_id FROM catalog_product_entity_int AS t WHERE (entity_id = '156494') AND (attribute_id IN (1440, 80, 474, 1124, 807, 1391, 1172, 1227, 1119, 1434, 541, 502, 759, 1441, 1453, 540, 503, 537, 471, 1370, 1274, 1443, 1445, 1437, 1540, 1353, 1416, 74, 1438, 1497, 1350, 470, 585, 1364, 81, 473, 500, 1351, 1361, 815, 1409, 1428, 1405, 1406, 472, 749, 841, 85, 538, 1111, 1334, 1366, 1371, 1408, 767, 1489, 1543, 1394, 1545, 607, 1238, 1239, 1345, 1352, 1369, 1419, 1420, 1421, 871, 1342, 1382, 1384, 1365, 1476, 1499, 1500, 1498, 1495, 1491, 1503, 1526, 1504, 1508, 1528, 1544, 475, 573, 773, 775, 777, 779, 781, 785, 787, 789, 963, 964, 965, 968)) AND (store_id IN (6, 0)))UNION ALL(SELECT t.value, t.attribute_id, t.store_id FROM catalog_product_entity_text AS t WHERE (entity_id = '156494') AND (attribute_id IN (58, 57, 68, 1572, 1444, 89, 1507, 1478, 1479, 1480, 1510, 1529, 1547, 971)) AND (store_id IN (6, 0)))UNION ALL(SELECT t.value, t.attribute_id, t.store_id FROM catalog_product_entity_varchar AS t WHERE (entity_id = '156494') AND (attribute_id IN (70, 82, 90, 469, 1451, 1375, 1191, 1414, 1482, 56, 71, 67, 92, 1452, 1377, 1125, 1314, 1232, 1392, 1415, 72, 1430, 86, 1558, 1483, 1412, 1442, 1432, 69, 1429, 1127, 499, 1413, 1511, 79, 1514, 1212, 907, 1512, 1513, 1570, 1410, 83, 95, 96, 97, 1114, 1418, 1407, 514, 1108, 1222, 1354, 1393, 1359, 1379, 1390, 1277, 1477, 1515, 1525, 903, 1575, 476, 477, 783)) AND (store_id IN (6, 0)))UNION ALL(SELECT t.value, t.attribute_id, t.store_id FROM catalog_product_entity_decimal AS t WHERE (entity_id = '156494') AND (attribute_id IN (61, 1433, 1435, 1126, 64, 1436, 75, 60, 909, 1439, 84, 65, 765, 769, 771, 1297, 1355)) AND (store_id IN (6, 0)))UNION ALL(SELECT t.value, t.attribute_id, t.store_id FROM catalog_product_entity_datetime AS t WHERE (entity_id = '156494') AND (attribute_id IN (87, 62, 88, 63, 77, 78, 1387, 1388, 966)) AND (store_id IN (6, 0))) ) AS u ORDER BY store_id ASC

Proposed solution

There were some discussion short here
https://yegorshytikov.medium.com/adobemagento-commerce-eav-performance-issue-fix-included-8b1a45e98904

Therefore the only option here is - to call 2 queries: 1 for store_id = 5 and second - for store_id = 0 and then merge values in PHP in a loop. It is even faster - no joins in MySQL. Yes, 2 queries, but they are fast. During heavy loading hours the experiment shows, that DB in this case is loaded less and responds faster and is able to process more page views.

the only fix there is remove sort after select it has On complexity. MySQL Should create temporary table and sort when it can just rerun this magneto junk to PHP

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”.
@onlinebizsoft onlinebizsoft added the Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it label Jan 20, 2025
Copy link

m2-assistant bot commented Jan 20, 2025

Hi @onlinebizsoft. Thank you for your report.
To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce.


Join Magento Community Engineering Slack and ask your questions in #github channel.
⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
🕙 You can find the schedule on the Magento Community Calendar page.
📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

@engcom-Bravo engcom-Bravo added the Reported on 2.4.x Indicates original Magento version for the Issue report. label Jan 20, 2025
@github-project-automation github-project-automation bot moved this to Ready for Confirmation in Issue Confirmation and Triage Board Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reported on 2.4.x Indicates original Magento version for the Issue report. Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
Status: Ready for Confirmation
Development

No branches or pull requests

2 participants