我遇到了 Magento 2 拥有超过 1300 万种产品的问题。我们已经成功上传了 1300 万个产品,尽管速度很慢,而且它的工作方式类似于索引、产品页面和搜索页面。
在等待近 2 分钟内存耗尽后,我的前端类别页面现在无法打开,我们尝试分配 18GB 内存,但它卡在了这个查询上,并出现错误“内存耗尽”。
SELECT 1 AS status, e.entity_id, e.attribute_set_id, e.type_id,
e.created_at, e.updated_at, e.sku,
cat_index.position AS cat_index_position,
stock_status_index.stock_status AS is_salable
FROM catalog_product_flat_1 AS e
INNER JOIN catalog_category_product_index_store1 AS cat_index
ON cat_index.product_id=e.entity_id
AND cat_index.store_id=1
AND cat_index.category_id='4'
INNER JOIN cataloginventory_stock_status AS stock_status_index
ON e.entity_id = stock_status_index.product_id
AND stock_status_index.website_id = 0
AND stock_status_index.stock_id = 1
WHERE (stock_status_index.stock_status = 1)
任何人都可以建议我如何克服这个问题或加快进程和 MySQL 查询,我应该做哪些架构级别的更改才能使其在前端的类别列表页面上工作。我知道这是一个巨大的数据,但我们需要拥有这么多的产品。我们有一个非常好的服务器
英特尔至强 E5-2689v4
128 GB 内存
1200 GB 数据存储
我已经启用了平面目录产品和平面目录类别。
最佳答案
添加这些复合索引:
stock_status_index: (stock_status, website_id, stock_id, product_id)
e: (entity_id) -- unless that is the PRIMARY KEY
cat_index: (product_id, store_id, category_id)
如果这些还不够帮助,请提供EXPLAIN SELECT ...
和SHOW CREATE TABLE
。
关于mysql - 类别页面无法正常工作 Magento 2 包含超过 1300 万种产品,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55849409/