I put some research in this some time ago as we also had issues with that table.
report_viewed_product_index
is used for the recently viewed products. If you don't use this feature: Go and truncate :-)
If you use the recently views products functionality, check if your cron is set up correct. The entries for visitors that do no more exist in the log/visitor
table should then be removed automatically at the log_log_clean_after
event.
The clean method is inherited for Mage_Reports_Model_Resource_Product_Index_Viewed
from Mage_Reports_Model_Resource_Product_Index_Abstract
where this happens.
/**
* 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;
}