2

We came across three absolutely identical in structure tables in M2 DB:

  • cataloginventory_stock_status
  • cataloginventory_stock_status_idx
  • cataloginventory_stock_status_tmp

Anybody has any idea why such redundancy has been introduced?

6

the cataloginventory_stock_status is the one that is used for reading in the frontend.
In order to not interfere with the table reads, when the stock index is running it is writing in the _tmp and/or _idx table and when it's done, the values are moved to the main table.

The temporary table used is determined by this method \Magento\CatalogInventory\Model\ResourceModel\Indexer\Stock\DefaultStock::tableStrategy::getUseIdxTable().
So in case it is true, the _idx table is used as temporary table. Otherwise the _tmp table is used.

The _idx table is used when you rebuild all the indexes, but I didn't find a case when the _tmp table is used, or what's the difference is between them.
I will report back when/if I find our more.

  • For tables with '_tmp' suffix MEMORY storage engine is used. – V Korotun Jun 17 '16 at 15:41
  • cataloginventory_stock_status & cataloginventory_stock_status_idx which one is eligible for do some logic operations. @Marius – zus Apr 5 at 4:43
  • cataloginventory_stock_status. – Marius Apr 5 at 5:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.