Stop storing the entity object in the entity reference selection settings
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3541424. --> Reported by: [dieterholvoet](https://www.drupal.org/user/3567222) Related to !164 >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>Currently, the widget stores the entity object in the <code>#selection_settings</code> in order to pass it to the selection handler and use it there. This causes two issues:</p> <ul> <li>The whole entity is serialized and stored in a row in the <code>key_value</code> table, with <code>entity_autocomplete</code> as collection. This takes up unnecessary storage.</li> <li>For every different entity reference configuration, a new <code>entity_autocomplete</code> row is stored. Due to the dynamic nature of that entity object, a lot of (unnecessary) rows end up in the <code>key_value</code> table.</li> <li> </ul> <p>On a website where I'm using Tagify heavily this has resulted in a <code>key_value</code> table of 1.5 GiB.</p> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>Stop storing the entity in the selection settings.</p>
issue