切り捨ててもよいテーブルのリスト(/programming/12205714/list-of-tables-to-safely-truncate-in-magento)を読んでいましたが、表示されませんでした
report_viewed_product_indexテーブルは巨大で、データベースの復元には非常に長い時間がかかります。このデータを切り捨てるか、少なくとも最も古いデータを削除しても安全ですか?
切り捨ててもよいテーブルのリスト(/programming/12205714/list-of-tables-to-safely-truncate-in-magento)を読んでいましたが、表示されませんでした
report_viewed_product_indexテーブルは巨大で、データベースの復元には非常に長い時間がかかります。このデータを切り捨てるか、少なくとも最も古いデータを削除しても安全ですか?
回答:
私が知る限り、この表はイベントに含まれていますlog_log_clean_after。
ファイルの下app/code/core/Mage/Reports/etc/config.xmlを見ると、次のスニペットが表示されます。
<events>
    <log_log_clean_after>
        <observers>
            <reports>
                <class>reports/event_observer</class>
                <method>eventClean</method>
            </reports>
        </observers>
    </log_log_clean_after>
</events>
この方法では、すべてのレポートイベントがクリーンアップされ、次に製品が表示および比較されるテーブルがクリーンアップされます。
public function eventClean(Varien_Event_Observer $observer)
{
    /* @var $event Mage_Reports_Model_Event */
    $event = Mage::getModel('reports/event');
    $event->clean();
    Mage::getModel('reports/product_index_compared')->clean();
    Mage::getModel('reports/product_index_viewed')->clean();
    return $this;
}
logClean cronセットアップがあることを確認したら、レポートもそれでクリーンアップする必要があります。
このテーブルにも問題があったので、少し前にこれについて調査しました。
report_viewed_product_index最近表示された製品に使用されます。この機能を使用しない場合:Go and truncate :-)
最近表示した製品の機能を使用している場合は、cronが正しく設定されているかどうかを確認してください。log/visitorテーブルに存在しなくなった訪問者のエントリは、log_log_clean_afterイベント時に自動的に削除されます。
cleanメソッドは、これが発生Mage_Reports_Model_Resource_Product_Index_ViewedするMage_Reports_Model_Resource_Product_Index_Abstract場所から継承されます。
/**
 * Clean index (visitor)
 *
 * @return Mage_Reports_Model_Resource_Product_Index_Abstract
 */
public function clean()
{
while (true) {
    $select = $this->_getReadAdapter()->select()
        ->from(array('main_table' => $this->getMainTable()), array($this->getIdFieldName()))
        ->joinLeft(
            array('visitor_table' => $this->getTable('log/visitor')),
            'main_table.visitor_id = visitor_table.visitor_id',
            array())
        ->where('main_table.visitor_id > ?', 0)
        ->where('visitor_table.visitor_id IS NULL')
        ->limit(100);
    $indexIds = $this->_getReadAdapter()->fetchCol($select);
    if (!$indexIds) {
        break;
    }
    $this->_getWriteAdapter()->delete(
        $this->getMainTable(),
        $this->_getWriteAdapter()->quoteInto($this->getIdFieldName() . ' IN(?)', $indexIds)
    );
}
return $this;
}