As a result, all other requests are blocked. These problems have two major slowdowns.
One is in Mage / Sales / Model / Mysql4 / Quote.php, there are two subqueries. I donβt know how MySQL cache works and how to configure MySQL on HostGator, so I end up caching the query result:
public function markQuotesRecollectOnCatalogRules() { $products = $this->_getReadAdapter()->fetchCol("SELECT DISTINCT product_id FROM {$this->getTable('catalogrule/rule_product_price')}"); $ids = $this->_getReadAdapter()->fetchCol(" SELECT DISTINCT quote_id FROM {$this->getTable('sales/quote_item')} WHERE product_id IN (?)", implode(',', $products) ); if (count($ids) > 0) { $this->_getWriteAdapter()->query(" UPDATE {$this->getTable('sales/quote')} SET trigger_recollect = 1 WHERE entity_id IN (?)", implode(',', $ids) ); } }
and
public function markQuotesRecollect($productIds) { $ids = $this->_getReadAdapter()->fetchCol(" SELECT DISTINCT quote_id FROM {$this->getTable('sales/quote_item')} WHERE product_id IN (?)", $productIds ); if (count($ids) > 0) { $this->_getWriteAdapter()->query(" UPDATE {$this->getTable('sales/quote')} SET trigger_recollect = 1 WHERE entity_id IN (?)", implode(',', $ids) ); } return $this; }
And there is Mage / CatalogRule / Model / Rule.php. Inside, this seems to be a well-known re-indexing issue.
public function applyAllRulesToProduct($product) { $this->_getResource()->applyAllRulesForDateRange(NULL, NULL, $product); $this->_invalidateCache(); if ($product instanceof Mage_Catalog_Model_Product) { $id = $product->getId(); } else { $id = $product; } if ($id) { $indexer = Mage::getResourceSingleton('catalog/product_indexer_price'); if ($indexer) { $indexer->reindexProductIds(array($id)); } } }
I think that making the answer to global settings better. But I donβt have time for this, so I copied this solution.
source share