by Ivan Chepurnyi
It does not make sense to flatten EAV structure for retrieval
Using price or stock index in shopping cart is a bad idea
Index generation can create a lock on table you don't expect
UDPATE some_index_table index
INNER JOIN catalog_product_entity_varchar product_data ON ...
SET index.some_value = product_data.value
MySQL memory consuption is increasing with amount of records you need to update.
These are known MySQL serial killers:
INSERT INTO .. SELECT ... FROM
UPDATE ... JOIN ... SET ...
Range your updates into smaller data-sets
During re-indexation there is a step when index table is locked and no data is available in it.
It was a nightmare comparing to Magento 2.0...
indexer.xml
and mview.xml
Allows you to subscribe to changes in any table
Magento\Framework\Mview\ActionInterface
<view id="mview_id" class="MviewClass" group="indexer">
<subscriptions>
<table name="table_to_check"
entity_column="primary_key" />
</subscriptions>
</view>
Just a regular Magento indexer definition
Magento\Framework\Indexer\ActionInterface
<indexer id="indexer_code" view_id="mview_code"
class="YourIndexerClass">
<title translate="true">Your Title</title>
<description translate="true">Your Description</description>
</indexer>
So how to implement HA index in Magento 2.0?
I really like re-usable components
So I come up with such indexer structure
interface IndexerInterface
{
public function executeFull();
public function executeByIds(array $ids);
}
use Magento\Framework\Db\Ddl\Table;
interface ListGeneratorInterface
{
/**
* @return Table
*/
public function generate(ConditionInterface $condition);
}
use Magento\Framework\DB\Select;
interface ConditionInterface
{
public function apply(
Select $select,
$alias,
array $columnMap = []
);
}
interface DataGeneratorInterface
{
/**
* @return Table
*/
public function generate(Table $listTable);
}
interface ProcessorInterface
{
public function process($conditions, $live = false);
}
interface MetadataInterface
{
public function getTableToIndex($live = false);
public function getIndexTable();
public function toggleTable();
public function getAttributesInfo($entityType, $attributeCodes);
}
Created in 3 hours during the workshop on the first #DevParadise day
Catch me at coffee break or during after party!
@IvanChepurnyi
ivan@ecomdev.org