Skip to content

Commit 7358174

Browse files
authored
Added two indexes on sales_flat_order and sales_flat_order_item tables (OpenMage#2447)
1 parent 27447f9 commit 7358174

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

app/code/core/Mage/Sales/etc/config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<config>
2323
<modules>
2424
<Mage_Sales>
25-
<version>1.6.0.10</version>
25+
<version>1.6.0.11</version>
2626
</Mage_Sales>
2727
</modules>
2828
<global>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
/**
3+
* OpenMage
4+
*
5+
* NOTICE OF LICENSE
6+
*
7+
* This source file is subject to the Open Software License (OSL 3.0)
8+
* that is bundled with this package in the file LICENSE.txt.
9+
* It is also available through the world-wide-web at this URL:
10+
* https://opensource.org/licenses/osl-3.0.php
11+
* If you did not receive a copy of the license and are unable to
12+
* obtain it through the world-wide-web, please send an email
13+
* to license@magento.com so we can send you a copy immediately.
14+
*
15+
* @category Mage
16+
* @package Mage_Sales
17+
* @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com)
18+
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19+
*/
20+
21+
/** @var Mage_Sales_Model_Entity_Setup $installer */
22+
$installer = $this;
23+
$installer->startSetup();
24+
25+
// Add index to sales_flat_order on customer_email for fast lookup, only first 15 bytes
26+
$keyList = $installer->getConnection()->getIndexList($installer->getTable('sales/order'));
27+
if (!isset($keyList['IDX_SALES_FLAT_ORDER_CUSTOMER_EMAIL'])) {
28+
$installer->run("
29+
ALTER TABLE {$installer->getTable('sales/order')}
30+
ADD INDEX `IDX_SALES_FLAT_ORDER_CUSTOMER_EMAIL` (`customer_email` (15));
31+
");
32+
}
33+
34+
// Add index to sales_flat_order_item.product_id for fast join/lookup
35+
$this->getConnection()->addIndex(
36+
$installer->getTable('sales/order_item'),
37+
'IDX_SALES_FLAT_ORDER_ITEM_PRODUCT_ID',
38+
['product_id']
39+
);
40+
41+
$installer->endSetup();

0 commit comments

Comments
 (0)