Ok to truncate report_viewed_product_index


12

मैं उन तालिकाओं की सूची के माध्यम से पढ़ रहा था जो ठीक करने के लिए ठीक हैं ( /programming/12205714/list-of-tables-to-safely-truncate-in-magento ) और मैंने नहीं देखा

report_viewed_product_index

तालिका बहुत बड़ी है और डेटाबेस को पुनर्स्थापित करने में बहुत लंबा समय लगता है। क्या इस डेटा को कम करना या सबसे पुराने डेटा को हटाना सुरक्षित है?


1
दिलचस्प सवाल, btw। मैंने कुछ समय पहले ऐसा ही सोचा था :)
— अन्ना वोक्कल

जवाबों:


17

जहाँ तक मैं देख / जान सकता हूँ यह तालिका घटना में शामिल है 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 सेटअप है तो रिपोर्ट को भी इसके साथ साफ किया जाना चाहिए।


अच्छा जवाब, डेविड :)
— अन्ना वोकल

12

मैंने कुछ समय पहले इसमें कुछ शोध किया था क्योंकि हमारे पास उस तालिका के साथ भी मुद्दे थे। report_viewed_product_indexहाल ही में देखे गए उत्पादों के लिए उपयोग किया जाता है। यदि आप इस सुविधा का उपयोग नहीं करते हैं: जाओ और छोटा करें :-)

यदि आप हाल ही में देखे गए उत्पादों की कार्यक्षमता का उपयोग करते हैं, तो जांचें कि क्या आपका क्रोन सही सेट है। विज़िटर के लिए प्रविष्टियाँ जो log/visitorतालिका में मौजूद नहीं हैं, तब log_log_clean_afterघटना पर स्वचालित रूप से हटा दी जानी चाहिए ।

स्वच्छ विधि विरासत में मिली 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;
}

ख़ुद भी बुरा नहीं है;)
— डेविड मैनर्स

हम्म, हमारे पास विज़िटर के साथ बहुत सारे रिकॉर्ड हैं। यह रिपोर्ट_व्यूस्ड_प्रोडक्ट_इंडेक्स में NULL है - ऐसा लगता है कि इन रिकॉर्ड्स को हटाया नहीं जाएगा
— Jiří Chmiel
हमारी साइट का प्रयोग करके, आप स्वीकार करते हैं कि आपने हमारी Cookie Policy और निजता नीति को पढ़ और समझा लिया है।
Licensed under cc by-sa 3.0 with attribution required.