【发布时间】:2014-06-13 14:01:09
【问题描述】:
我在 magento 应用程序(社区版)上有大约 2.5 lachs (250K) 产品和 2600 个子类别。
查询
SELECT 1 status
, e.entity_id
, e.type_id
, e.attribute_set_id
, cat_index.position AS cat_index_position
, e.name
, e.description
, e.short_description
, e.price
, e.special_price
, e.special_from_date
, e.special_to_date
, e.cost
, e.small_image
, e.thumbnail
, e.color
, e.color_value
, e.news_from_date
, e.news_to_date
, e.url_key
, e.required_options
, e.image_label
, e.small_image_label
, e.thumbnail_label
, e.msrp_enabled
, e.msrp_display_actual_price_type
, e.msrp
, e.tax_class_id
, e.price_type
, e.weight_type
, e.price_view
, e.shipment_type
, e.links_purchased_separately
, e.links_exist
, e.open_amount_min
, e.open_amount_max
, e.custom_h1
, e.awards
, e.region
, e.grape_type
, e.food_match
, e.udropship_vendor
, e.upc_barcode
, e.ean_barcode
, e.mpn
, e.size
, e.author
, e.format
, e.pagination
, e.publish_date
, price_index.price
, price_index.tax_class_id
, price_index.final_price
, IF(price_index.tier_price IS NOT NULL
, LEAST(price_index.min_price
, price_index.tier_price)
, price_index.min_price) AS minimal_price
, price_index.min_price
, price_index.max_price
, price_index.tier_price
FROM catalog_product_flat_1 e
JOIN catalog_category_product_index cat_index
ON cat_index.product_id = e.entity_id
AND cat_index.store_id = 1
AND cat_index.visibility IN(2,4)
AND cat_index.category_id = 163
JOIN catalog_product_index_price price_index
ON price_index.entity_id = e.entity_id
AND price_index.website_id = 1
AND price_index.customer_group_id = 0
GROUP
BY e.entity_id
ORDER
BY cat_index_position ASC
, cat_index.position ASC
LIMIT 15;
每当访问这个 magento 站点上的任何产品时,它都会在服务器上的 /tmp 目录下创建一个大约 10 GB 的巨大数据。
我该如何解决这个问题,请提出一些解决方案。
数据库大小为 50 GB,服务器为 nginx。
【问题讨论】:
-
运行您描述的查询,但将 EXPLAIN EXTENDED 放在它前面。输出是什么。此外,尝试摆脱 ORDER BY 并使用 EXPLAIN EXTENDED 运行查询。也发布该输出。
-
在没有任何聚合函数的情况下,我认为使用 GROUP BY 子句是不合适的,并且会提供误导性结果。
-
您的 MySQL 配置是否针对 Magento 进行了优化?见magentospeedup.com/2013/05/31/…
-
您使用的是平面类别表吗?
标签: mysql magento nginx database-performance