1
當我看到大多數瀏覽過的產品收集代碼,SQL查詢顯示Magento的:數據庫的優化
SELECT COUNT(_table_views.event_id) AS `views`, `e`.*, `cat_index`.`position` AS `cat_index_position`
FROM `report_event` AS `_table_views`
INNER JOIN `catalog_product_entity` AS `e` ON e.entity_id = _table_views.object_id AND e.entity_type_id = 4
INNER JOIN `catalog_category_product_index` AS `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='2'
WHERE (_table_views.event_type_id = '1')
GROUP BY `e`.`entity_id`
HAVING (views > 0)
ORDER BY `views` desc
望着數據庫中的表report_event是一個巨大的,它沒有任何意義做一組通過或指望每一次。
最好每天爲此構建一個聚合表(幾乎就像一個索引)。我想知道是否有人曾經這樣做過,哪裏是開始的好地方。
彙總表格可以
SELECT (_table_views.object_id) AS `entity_id`, COUNT(_table_views.event_id) AS `views`,
FROM `report_event` AS `_table_views`
WHERE (_table_views.event_type_id = '1')
GROUP BY `e`.`entity_id`
整體來說,我認爲這將是很好的Magento的產品作爲一個整體,如果瓦里安其加入到核心文件。
順便說一句,我還看到另一個表report_viewed_product_index和爲什麼沒有被用來做此查詢...