{"id":16293,"date":"2018-07-17T14:33:26","date_gmt":"2018-07-17T12:33:26","guid":{"rendered":"https:\/\/belvg.com\/blog\/?p=16293"},"modified":"2021-02-18T14:03:12","modified_gmt":"2021-02-18T12:03:12","slug":"how-eav-data-storage-works-in-magento-2-part-2","status":"publish","type":"post","link":"https:\/\/belvg.com\/blog\/how-eav-data-storage-works-in-magento-2-part-2.html","title":{"rendered":"How EAV Data Storage Works in Magento 2: Part 2"},"content":{"rendered":"\n<p>There is not much difference for a developer in EAV and Flat collections. The creation of models, resource models and collections is very similar. Let&rsquo;s describe the key differences between EAV and flat table collections and consider creating classes for EAV (City) and Flat (Country). This is Part 2 of the EAV data storage review, check out <a href=\"https:\/\/belvg.com\/blog\/how-eav-data-storage-works-in-magento-2.html\" target=\"_blank\" rel=\"noopener\">Part 1<\/a> to catch up on the topic.<\/p>\n<p><!--more--> <a href=\"#par_1\">Collections<\/a><br>\n<a href=\"#par_2\">Resource models<\/a><br>\n<a href=\"#par_3\">Models<\/a><br>\n<a href=\"#par_4\">The differences between EAV and FLAT classes<\/a><br>\n<a href=\"#par_5\">When to use EAV for a new entity<\/a><br>\n<a href=\"#par_6\">The pros and cons of EAV architecture<\/a><\/p>\n<h2><a id=\"par_1\"><\/a><strong><span style=\"color: #000000;\">Collections<\/span><\/strong><\/h2>\n<p><span style=\"color: #000000;\">EAV<\/span><\/p>\n<pre class=\"lang:php decode:true\">&lt;?php\r\nnamespace Belvg\\Geo\\Model\\ResourceModel\\City;\r\nclass Collection extends \\Magento\\Eav\\Model\\Entity\\Collection\\AbstractCollection\r\n{\r\n&nbsp;&nbsp;&nbsp;protected function _construct()\r\n&nbsp;&nbsp;&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;_init(\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'Belvg\\Geo\\Model\\City',\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'Belvg\\Geo\\Model\\ResourceModel\\City'\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);\r\n&nbsp;&nbsp;&nbsp;}\r\n}<\/pre>\n<h4><span style=\"color: #000000;\">Flat<\/span><\/h4>\n<pre class=\"lang:php decode:true\">&lt;?php\r\nnamespace Belvg\\Geo\\Model\\ResourceModel\\Country;\r\nclass Collection extends \\Magento\\Framework\\Model\\ResourceModel\\Db\\Collection\\AbstractCollection\r\n{\r\n&nbsp;&nbsp;&nbsp;protected function _construct()\r\n&nbsp;&nbsp;&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;_init(\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'Belvg\\Geo\\Model\\Country',\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'Belvg\\Geo\\Model\\ResourceModel\\Country'\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);\r\n&nbsp;&nbsp;&nbsp;}\r\n}<\/pre>\n<div class=\"module_in_content_container\"><a href=\"https:\/\/belvg.com\/magento-webdesign\" class=\"link_to_module\" target=\"_blank\" rel=\"noopener\"><\/a><div class=\"module_content\"><img src=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2019\/01\/magento-webdesign-1.png\" width=\"100\" height=\"100\" alt=\"magento webdesign\" class=\"module_image\" title=\"How EAV Data Storage Works in Magento 2: Part 2\"><div class=\"module_content_part\"><h3 class=\"title\">Magento Webdesign<\/h3><p class=\"module_content_text\">Take your online store to the next level with BelVG Magento Webdesign<\/p><a href=\"https:\/\/belvg.com\/magento-webdesign\" class=\"link_2_to_module\" target=\"_blank\" style=\"display:inline-block\" rel=\"noopener\"><span class=\"read-more\">Visit the page<\/span><\/a><\/div><\/div><\/div>\n<h2><a id=\"par_2\"><\/a><strong><span style=\"color: #000000;\">Resource models<\/span><\/strong><\/h2>\n<p><span style=\"color: #000000;\">EAV<\/span><\/p>\n<pre class=\"lang:php decode:true\">&lt;?php\r\nnamespace Belvg\\Geo\\Model\\ResourceModel;\r\nclass City extends \\Magento\\Eav\\Model\\Entity\\AbstractEntity\r\n{\r\n&nbsp;&nbsp;&nbsp;public function getEntityType()\r\n&nbsp;&nbsp;&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (empty($this-&gt;_type)) {\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;setType(\\Belvg\\Geo\\Model\\City::ENTITY);\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return parent::getEntityType();\r\n&nbsp;&nbsp;&nbsp;}\r\n}<\/pre>\n<p><span style=\"color: #000000;\">Flat<\/span><\/p>\n<pre class=\"lang:php decode:true\">&lt;?php\r\nnamespace Belvg\\Geo\\Model\\ResourceModel;\r\nclass Country extends \\Magento\\Framework\\Model\\ResourceModel\\Db\\AbstractDb\r\n{\r\n&nbsp;&nbsp;&nbsp;protected function _construct()\r\n&nbsp;&nbsp;&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;_init(\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'belvg_geo_country',\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'entity_id'\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);\r\n&nbsp;&nbsp;&nbsp;}\r\n}<\/pre>\n<h2><a id=\"par_3\"><\/a><strong><span style=\"color: #000000;\">Models<\/span><\/strong><\/h2>\n<p><span style=\"color: #000000;\">EAV<\/span><\/p>\n<pre class=\"lang:php decode:true\">&lt;?php\r\nnamespace Belvg\\Geo\\Model;\r\nclass City extends \\Magento\\Framework\\Model\\AbstractModel\r\n{\r\n&nbsp;&nbsp;&nbsp;const ENTITY = 'belvg_geo_city';\r\n\r\n&nbsp;&nbsp;&nbsp;protected function _construct()\r\n&nbsp;&nbsp;&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;_init('Belvg\\Geo\\Model\\ResourceModel\\City');\r\n&nbsp;&nbsp;&nbsp;}\r\n}<\/pre>\n<p><span style=\"color: #000000;\">Flat<\/span><\/p>\n<pre class=\"lang:php decode:true\">&lt;?php\r\nnamespace Belvg\\Geo\\Model;\r\nclass Country extends \\Magento\\Framework\\Model\\AbstractModel\r\n{\r\n&nbsp;&nbsp;&nbsp;protected function _construct()\r\n&nbsp;&nbsp;&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;_init('Belvg\\Geo\\Model\\ResourceModel\\Country');\r\n&nbsp;&nbsp;&nbsp;}\r\n}<\/pre>\n<h2><a id=\"par_4\"><\/a><span style=\"color: #000000;\"><strong>The differences between EAV and FLAT classes<\/strong><\/span><\/h2>\n<p>Additionally, methods that take an attribute parameter as its code or its object have been added in the EAV collection:<\/p>\n<ul>\n<li><span style=\"color: #000000;\">addAttributeToSelect converts the attribute into its code and calls addFieldToSelect;<\/span><\/li>\n<li><span style=\"color: #000000;\">addAttributeToFilter converts the attribute into its code and calls addFieldToFilter;<\/span><\/li>\n<li><span style=\"color: #000000;\">addAttributeToSort converts the attribute into its code and calls addOrder.<\/span><\/li>\n<\/ul>\n<p>Additionally, methods for working with attributes have been added in EAV resource models, the methods load, save, delete have been redefined.<\/p>\n<div class=\"content_sales_info\" style=\"background-image: url(https:\/\/belvg.com\/blog\/wp-content\/uploads\/2019\/03\/Sales_background.png\"><img width=\"65\" height=\"65\" src=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2019\/03\/Igor-Dragun1.png\" alt=\"Igor Dragun\" title=\"How EAV Data Storage Works in Magento 2: Part 2\"><div class=\"content_part\"><h3 class=\"title\">Partner With Us <\/h3><span class=\"sales_content_text\">Let's discuss how to grow your business. Get a Free Quote.<\/span><\/div> <a class=\"call-to-action\" href=\"https:\/\/belvg.com\/contact?utm_source=blog&amp;utm_campaign=sales_block&amp;utm_content=middle\" target=\"_blank\" rel=\"noopener\">Talk to Igor<\/a><\/div>\n<p>EAV uses the following classes for working with attributes:<\/p>\n<ul>\n<li><span style=\"color: #000000;\">Magento\\Eav\\Model\\ResourceModel\\CreateHandler &mdash; for creating values in new entities;<\/span><\/li>\n<li><span style=\"color: #000000;\">Magento\\Eav\\Model\\ResourceModel\\UpdateHandler&nbsp;&mdash; for modifying \/ deleting \/ adding values to existing entities;<\/span><\/li>\n<li><span style=\"color: #000000;\">Magento\\Eav\\Model\\ResourceModel\\ReadHandler&nbsp;&mdash; for obtaining values.<\/span><\/li>\n<\/ul>\n<p><span style=\"color: #000000;\">The key difference between EAV and Flat is the storage of data. Read more about it in the <span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/belvg.com\/blog\/how-eav-data-storage-works-in-magento-2.html\">previous article<\/a><\/span> on EAV data storage.<\/span><\/p>\n<p>There are options like Use Flat Catalog Category and Use Flat Catalog Product at <strong>STORES &#10140; Settings &#10140; Configuration<\/strong>&nbsp;on the Admin panel. These settings allow you to change the sources from which products and categories are loaded, from the EAV tables to the FLAT index tables.<\/p>\n<p>A product&rsquo;s attribute falls into a flat table if it satisfies one of the conditions:<\/p>\n<ul>\n<li><span style=\"color: #000000;\">backend_type is specified as static;<\/span><\/li>\n<li><span style=\"color: #000000;\">a filter for this field is allowed;<\/span><\/li>\n<li><span style=\"color: #000000;\">the attribute is used in the product list;<\/span><\/li>\n<li><span style=\"color: #000000;\">the attribute is used for sorting.<\/span><\/li>\n<\/ul>\n<p>The collection of products is a Magento\\Catalog\\Model\\ResourceModel\\Product\\Collection class. In this class, many methods have the following form:<\/p>\n<pre class=\"lang:php decode:true\">if ($this-&gt;isEnabledFlat()) {\r\n...\r\n} else {\r\n...\r\n}<\/pre>\n<p>That is, if Flat is enabled, then one action is performed, if it is off, then the other.<\/p>\n<p>It&rsquo;s different with categories. The Magento\\Catalog\\Model\\Category model is initialized as follows:<\/p>\n<pre class=\"lang:php decode:true\">&nbsp;protected function _construct()\r\n&nbsp;&nbsp;&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ If Flat Index enabled then use it but only on frontend\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($this-&gt;flatState-&gt;isAvailable()) {\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;_init(\\Magento\\Catalog\\Model\\ResourceModel\\Category\\Flat::class);\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;_useFlatResource = true;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else {\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;_init(\\Magento\\Catalog\\Model\\ResourceModel\\Category::class);\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\r\n&nbsp;&nbsp;&nbsp;}<\/pre>\n<p>That is, different resource models are used.<\/p>\n<p>Collections are also divided into 2 different classes, in contrast to the products:<\/p>\n<ul>\n<li><span style=\"color: #000000;\">Magento\\Catalog\\Model\\ResourceModel\\Category\\Collection<\/span><\/li>\n<li><span style=\"color: #000000;\">Magento\\Catalog\\Model\\ResourceModel\\Category\\Flat\\Collection<\/span><\/li>\n<\/ul>\n<div class=\"module_in_content_container\"><a href=\"https:\/\/belvg.com\/migration-to-magento-2\" class=\"link_to_module\" target=\"_blank\" rel=\"noopener\"><\/a><div class=\"module_content\"><img src=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2019\/06\/migration-to-magento-2.png\" width=\"100\" height=\"100\" alt=\"migration to magento 2\" class=\"module_image\" title=\"How EAV Data Storage Works in Magento 2: Part 2\"><div class=\"module_content_part\"><h3 class=\"title\">Magento 2 Migration<\/h3><p class=\"module_content_text\">Take your online store to the next level with BelVG Magento 2 Migration<\/p><a href=\"https:\/\/belvg.com\/migration-to-magento-2\" class=\"link_2_to_module\" target=\"_blank\" style=\"display:inline-block\" rel=\"noopener\"><span class=\"read-more\">Visit the page<\/span><\/a><\/div><\/div><\/div>\n<h2><a id=\"par_5\"><\/a><strong><span style=\"color: #000000;\">When&nbsp;to use EAV for a new entity<\/span><\/strong><\/h2>\n<p>I will use EAV for the entity if at least one of the conditions is fulfilled:<\/p>\n<ol>\n<li><span style=\"color: #000000;\">The scope should be presented in the entity.<\/span><\/li>\n<li><span style=\"color: #000000;\">Administrators or modules should be able to add attributes to the entity or change the backend type of attributes.<\/span><\/li>\n<li><span style=\"color: #000000;\">Potentially the number of columns can be more than 1017 in a Flat model.<\/span><\/li>\n<li><span style=\"color: #000000;\">The potentially required number of indexes of the INDEX type in a Flat model can become more than 64 or so many, that the operations of adding\/changing\/deleting entities will be too slow.<\/span><\/li>\n<\/ol>\n<h2><a id=\"par_6\"><\/a><span style=\"color: #000000;\"><strong>The pros and cons of EAV architecture<\/strong><\/span><\/h2>\n<h4><span style=\"color: #000000;\">The advantages of EAV over Flat<\/span><\/h4>\n<ul>\n<li><span style=\"color: #000000;\">The implementation of SCOPE in Flat models stores a lot of unnecessary information. For example, if you want to override only one attribute in another scope, both EAV and Flat will create one line. But EAV always has a fixed number of columns, and in <\/span>Flat it<span style=\"color: #000000;\"> can reach up to 1000. Additionally, a problem arises when the value is inherited from the parent scope. You can mark such values as NULL, but then you must disallow the attributes to be NULL if they are not inherited.<\/span><\/li>\n<li><span style=\"color: #000000;\">Quick adding of a new attribute. Adding a new attribute does not change the EAV table in any way. In Flat you need to add a new column for this. The ALTER TABLE operation is slow. This is especially noticeable in large tables. *<\/span><\/li>\n<li><span style=\"color: #000000;\">Faster change of the backend type of an attribute. To change the attribute type in EAV, you need to move the data of this attribute from one table to another. For Flat, you need to execute <\/span>ALTER<span style=\"color: #000000;\"> TABLE. *<\/span><\/li>\n<li><span style=\"color: #000000;\">EAV allows you to separate attribute values from the values of the fields of the entity.<\/span><\/li>\n<li><span style=\"color: #000000;\">The following InnoDB restrictions on the table limit Flat:<\/span>\n<ul>\n<li><span style=\"color: #000000;\">The table can contain no more than 1017 columns<\/span><\/li>\n<li><span style=\"color: #000000;\">A table can contain no more than 64 indices of the INDEX type<\/span><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h4><span style=\"color: #000000;\">The disadvantages of EAV over Flat<\/span><\/h4>\n<ul>\n<li><span style=\"color: #000000;\">Obtaining the attributes values of an entity in EAV works slower than in Flat **<\/span><\/li>\n<li><span style=\"color: #000000;\">Search by attribute value in EAV works slower than in Flat **<\/span><\/li>\n<li><span style=\"color: #000000;\">In Flat, you can create an index for several attributes to speed up the search **<\/span><\/li>\n<\/ul>\n<p>* ALTER TABLE is performed while adding or changing an attribute type in EAV too if the backend type of the attribute is static.<\/p>\n<p>** To speed up operations, some attributes can be set the backend type as static and, if necessary, create indexes, but then the scope of the attribute will only be global. Another option is to use a flat table as an index if it is allowed for the data to delay in actuality.<\/p>\n<div class=\"module_in_content_container\"><a href=\"https:\/\/belvg.com\/magento-custom-development\" class=\"link_to_module\" target=\"_blank\" rel=\"noopener\"><\/a><div class=\"module_content\"><img src=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2019\/01\/magento-custom-development.png\" width=\"120\" height=\"120\" alt=\"magento custom development\" class=\"module_image\" title=\"How EAV Data Storage Works in Magento 2: Part 2\"><div class=\"module_content_part\"><h3 class=\"title\">Magento Custom Development<\/h3><p class=\"module_content_text\">Take your online store to the next level with BelVG Magento Custom Development <\/p><a href=\"https:\/\/belvg.com\/magento-custom-development\" class=\"link_2_to_module\" target=\"_blank\" style=\"display:inline-block\" rel=\"noopener\"><span class=\"read-more\">Visit the page<\/span><\/a><\/div><\/div><\/div>\n\n","protected":false},"excerpt":{"rendered":"How the EAV data storage system works in Magneto 2.","protected":false},"author":82,"featured_media":16296,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"image","meta":{"_acf_changed":false,"footnotes":""},"categories":[491,389,524],"tags":[],"class_list":["post-16293","post","type-post","status-publish","format-image","has-post-thumbnail","hentry","category-magento-2","category-magento2-development","category-magento-speed-optimization","post_format-post-format-image"],"acf":[],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.4 - aioseo.com -->\n\t<meta name=\"description\" content=\"The principles of EAV data storage work in Magento 2. The differences between EAV and Flat classes, the advantages and disadvantages of EAV over Flat.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Andrey Litvin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/belvg.com\/blog\/how-eav-data-storage-works-in-magento-2-part-2.html\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.4\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-eav-data-storage-works-in-magento-2-part-2.html#article\",\"name\":\"Working with EAV data storage in Magento 2: Part 2 | BelVG Blog\",\"headline\":\"How EAV Data Storage Works in Magento 2: Part 2\",\"author\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrey-litvin#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/07\\\/How-EAV-Data-Storage-Works-in-Magento-2-part-2.jpg\",\"width\":770,\"height\":433},\"datePublished\":\"2018-07-17T14:33:26+02:00\",\"dateModified\":\"2021-02-18T14:03:12+02:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-eav-data-storage-works-in-magento-2-part-2.html#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-eav-data-storage-works-in-magento-2-part-2.html#webpage\"},\"articleSection\":\"Magento 2, Magento 2 Development, Magento Speed Optimization, Image\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-eav-data-storage-works-in-magento-2-part-2.html#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development#listItem\",\"name\":\"Magento 2 Development\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development#listItem\",\"position\":2,\"name\":\"Magento 2 Development\",\"item\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-eav-data-storage-works-in-magento-2-part-2.html#listItem\",\"name\":\"How EAV Data Storage Works in Magento 2: Part 2\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-eav-data-storage-works-in-magento-2-part-2.html#listItem\",\"position\":3,\"name\":\"How EAV Data Storage Works in Magento 2: Part 2\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development#listItem\",\"name\":\"Magento 2 Development\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\",\"name\":\"BelVG Blog\",\"description\":\"Magento and Prestashop articles\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrey-litvin#author\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrey-litvin\",\"name\":\"Andrey Litvin\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-eav-data-storage-works-in-magento-2-part-2.html#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/e1a6e3c80cb940fddb65016d94b015cd951b4a8a9cd7227565131f28ea95c7a0?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Andrey Litvin\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-eav-data-storage-works-in-magento-2-part-2.html#webpage\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-eav-data-storage-works-in-magento-2-part-2.html\",\"name\":\"Working with EAV data storage in Magento 2: Part 2 | BelVG Blog\",\"description\":\"The principles of EAV data storage work in Magento 2. The differences between EAV and Flat classes, the advantages and disadvantages of EAV over Flat.\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-eav-data-storage-works-in-magento-2-part-2.html#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrey-litvin#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrey-litvin#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/07\\\/How-EAV-Data-Storage-Works-in-Magento-2-part-2.jpg\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-eav-data-storage-works-in-magento-2-part-2.html\\\/#mainImage\",\"width\":770,\"height\":433},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-eav-data-storage-works-in-magento-2-part-2.html#mainImage\"},\"datePublished\":\"2018-07-17T14:33:26+02:00\",\"dateModified\":\"2021-02-18T14:03:12+02:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\",\"name\":\"BelVG Blog\",\"description\":\"Magento and Prestashop articles\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Working with EAV data storage in Magento 2: Part 2 | BelVG Blog","description":"The principles of EAV data storage work in Magento 2. The differences between EAV and Flat classes, the advantages and disadvantages of EAV over Flat.","canonical_url":"https:\/\/belvg.com\/blog\/how-eav-data-storage-works-in-magento-2-part-2.html","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/belvg.com\/blog\/how-eav-data-storage-works-in-magento-2-part-2.html#article","name":"Working with EAV data storage in Magento 2: Part 2 | BelVG Blog","headline":"How EAV Data Storage Works in Magento 2: Part 2","author":{"@id":"https:\/\/belvg.com\/blog\/author\/andrey-litvin#author"},"publisher":{"@id":"https:\/\/belvg.com\/blog\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/07\/How-EAV-Data-Storage-Works-in-Magento-2-part-2.jpg","width":770,"height":433},"datePublished":"2018-07-17T14:33:26+02:00","dateModified":"2021-02-18T14:03:12+02:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/belvg.com\/blog\/how-eav-data-storage-works-in-magento-2-part-2.html#webpage"},"isPartOf":{"@id":"https:\/\/belvg.com\/blog\/how-eav-data-storage-works-in-magento-2-part-2.html#webpage"},"articleSection":"Magento 2, Magento 2 Development, Magento Speed Optimization, Image"},{"@type":"BreadcrumbList","@id":"https:\/\/belvg.com\/blog\/how-eav-data-storage-works-in-magento-2-part-2.html#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/#listItem","position":1,"name":"Home","item":"https:\/\/belvg.com\/blog\/","nextItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento2-development#listItem","name":"Magento 2 Development"}},{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento2-development#listItem","position":2,"name":"Magento 2 Development","item":"https:\/\/belvg.com\/blog\/category\/magento2-development","nextItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/how-eav-data-storage-works-in-magento-2-part-2.html#listItem","name":"How EAV Data Storage Works in Magento 2: Part 2"},"previousItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/how-eav-data-storage-works-in-magento-2-part-2.html#listItem","position":3,"name":"How EAV Data Storage Works in Magento 2: Part 2","previousItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento2-development#listItem","name":"Magento 2 Development"}}]},{"@type":"Organization","@id":"https:\/\/belvg.com\/blog\/#organization","name":"BelVG Blog","description":"Magento and Prestashop articles","url":"https:\/\/belvg.com\/blog\/"},{"@type":"Person","@id":"https:\/\/belvg.com\/blog\/author\/andrey-litvin#author","url":"https:\/\/belvg.com\/blog\/author\/andrey-litvin","name":"Andrey Litvin","image":{"@type":"ImageObject","@id":"https:\/\/belvg.com\/blog\/how-eav-data-storage-works-in-magento-2-part-2.html#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/e1a6e3c80cb940fddb65016d94b015cd951b4a8a9cd7227565131f28ea95c7a0?s=96&d=mm&r=g","width":96,"height":96,"caption":"Andrey Litvin"}},{"@type":"WebPage","@id":"https:\/\/belvg.com\/blog\/how-eav-data-storage-works-in-magento-2-part-2.html#webpage","url":"https:\/\/belvg.com\/blog\/how-eav-data-storage-works-in-magento-2-part-2.html","name":"Working with EAV data storage in Magento 2: Part 2 | BelVG Blog","description":"The principles of EAV data storage work in Magento 2. The differences between EAV and Flat classes, the advantages and disadvantages of EAV over Flat.","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/belvg.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/belvg.com\/blog\/how-eav-data-storage-works-in-magento-2-part-2.html#breadcrumblist"},"author":{"@id":"https:\/\/belvg.com\/blog\/author\/andrey-litvin#author"},"creator":{"@id":"https:\/\/belvg.com\/blog\/author\/andrey-litvin#author"},"image":{"@type":"ImageObject","url":"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/07\/How-EAV-Data-Storage-Works-in-Magento-2-part-2.jpg","@id":"https:\/\/belvg.com\/blog\/how-eav-data-storage-works-in-magento-2-part-2.html\/#mainImage","width":770,"height":433},"primaryImageOfPage":{"@id":"https:\/\/belvg.com\/blog\/how-eav-data-storage-works-in-magento-2-part-2.html#mainImage"},"datePublished":"2018-07-17T14:33:26+02:00","dateModified":"2021-02-18T14:03:12+02:00"},{"@type":"WebSite","@id":"https:\/\/belvg.com\/blog\/#website","url":"https:\/\/belvg.com\/blog\/","name":"BelVG Blog","description":"Magento and Prestashop articles","inLanguage":"en-US","publisher":{"@id":"https:\/\/belvg.com\/blog\/#organization"}}]}},"aioseo_meta_data":{"post_id":"16293","title":"Working with EAV data storage in Magento 2: Part 2 | #site_title","description":"The principles of EAV data storage work in Magento 2. The differences between EAV and Flat classes, the advantages and disadvantages of EAV over Flat.","keywords":null,"keyphrases":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_custom_url":null,"og_image_custom_fields":null,"og_image_url":null,"og_image_width":null,"og_image_height":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_image_url":null,"twitter_title":null,"twitter_description":null,"schema_type":"default","schema_type_options":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null,"created":"2026-11-03 18:37:06","updated":"2026-11-03 18:37:06"},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/belvg.com\/blog\/\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/belvg.com\/blog\/category\/magento2-development\" title=\"Magento 2 Development\">Magento 2 Development<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tHow EAV Data Storage Works in Magento 2: Part 2\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/belvg.com\/blog\/"},{"label":"Magento 2 Development","link":"https:\/\/belvg.com\/blog\/category\/magento2-development"},{"label":"How EAV Data Storage Works in Magento 2: Part 2","link":"https:\/\/belvg.com\/blog\/how-eav-data-storage-works-in-magento-2-part-2.html"}],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/16293","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/users\/82"}],"replies":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/comments?post=16293"}],"version-history":[{"count":0,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/16293\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/media\/16296"}],"wp:attachment":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/media?parent=16293"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/categories?post=16293"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/tags?post=16293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}