I saw the numbers increasing in the mview_state table in the database and there is no cleanup.
So I wonder what's the purpose of this table and the values that we have there?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.Sign up to join this community
mview_state is a table enabling your indexes to feed their index tables.
That is the nutshell. Now, I have built a small dummy module with
index this week.
the index file is as follows:
<?xml version="1.0" encoding="UTF-8"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Indexer/etc/indexer.xsd"> <indexer id="cart_log" view_id="mbs_cart_log" class="Mbs\AdminScreen\Model\Indexer\CartLogCreator"> <title translate="true">Cart Log Data</title> <description translate="true">Create Cart Log data</description> </indexer> </config>
there is a mview file
<?xml version="1.0" encoding="UTF-8"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Mview/etc/mview.xsd"> <view id="mbs_cart_log" class="Mbs\AdminScreen\Model\Indexer\CartLogCreator" group="indexer"> <subscriptions> <table name="quote" entity_column="entity_id" /> </subscriptions> </view> </config>
The index is highly reliant on this
mview file. The latter dictates that when a quote record is created, the entity_id is eventually stored in _cl table.
I will now describe where this _cl table comes from. In my module, my index table is
mbs_cart_log. Magento will create a table called
mbs_cart_log_cl as soon as your indexer is successfully registered. And this is the table that gets a record when the new quote record gets created. Also, an additional mview_state record will be created with the name of your view_id (the one in
Once you have this working, then you just have to run the index you have just added, and you will see
mview_state table being updated with a version id that matches the _cl table latest record.
Finally, but not least, your index table will contain the records that the indexer function
executeFull will have extracted (mine is at \Mbs\AdminScreen\Model\Indexer\CartLogCreator::executeFull)