Skip to content

Commit

Permalink
1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrii-fediuk committed Nov 2, 2019
1 parent 881e5ad commit 544018f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions Framework/Indexer/Handler/FirstOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
class FirstOrder implements IHandler {
/**
* 2019-11-02
* The current solution (via `LEFT JOIN`) takes just 3 seconds on `bin/magento indexer:reindex customer_grid`.
* The previous colution (via a subquery) took almost 7 minutes on `bin/magento indexer:reindex customer_grid`:
* https://github.com/royalwholesalecandy/core/blob/1.0.0/Framework/Indexer/Handler/FirstOrder.php#L27-L31
* @override
* @see \Magento\Framework\Indexer\HandlerInterface::prepareSql()
* @used-by \Magento\Framework\Indexer\Action\Base::createResultCollection()
Expand All @@ -24,10 +27,14 @@ class FirstOrder implements IHandler {
* }
*/
function prepareSql(ISourceProvider $cc, $alias, $fieldInfo) {
$cc->getSelect()->columns(['first_date' => df_select()
->from(['so' => df_table('sales_order')], [])
->columns(['first_date' => new \Zend_Db_Expr('MIN(so.created_at)')])
->where('e.email = so.customer_email')
]);
$cc->getSelect()->joinLeft(
['so' => df_select()
->from(df_table('sales_order'), [])
->columns(['email' => 'customer_email', 'first_date' => new \Zend_Db_Expr('MIN(created_at)')])
->group('email')
]
,'e.email = so.email'
,['first_date']
);
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "royalwholesalecandy/core"
,"version": "1.0.0"
,"version": "1.0.1"
,"description": "A custom module for royalwholesalecandy.com (Magento 2)"
,"type": "magento2-module"
,"homepage": "https://github.com/royalwholesalecandy/core"
Expand Down

0 comments on commit 544018f

Please sign in to comment.