Typically, when a Magento store reaches 20,000 orders and more than 5 people load the sales-orders grid concurrently, our online store becomes extremely slow.
How do we solve it? simple. limiting the amount of orders presented in the orders grid for the last 24 hours, unless requested otherwise.
Copy the app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php file to:
app/code/local/Mage/Adminhtml/Block/Sales/Order/Grid.php
Edit the following function, copy-paste from here:
protected function _prepareCollection() {
$collection = Mage::getResourceModel($this->_getCollectionClass());
######################## FILTER BY LAST DAY ######################
$now = Mage::getModel('core/date')->timestamp(time());
$filter = $this->getParam($this->getVarNameFilter(), null); //important - check for other requested grid-filters before filtering today's orders
$dateStart = date('Y-m-d' . ' 00:00:00', $now);
$dateEnd = date('Y-m-d' . ' 23:59:59', $now);
$postData = Mage::app()->getRequest()->getPost();
if (empty($filter)) {
$collection->addFieldToFilter('`main_table`.created_at', array('from' => $dateStart, 'to' => $dateEnd));
}
##################################################################
$collection->getSelect()->group('entity_id');
$this->setCollection($collection);
return $this;
}