Possible performance improvement
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3368136. -->
Reported by: [nterbogt](https://www.drupal.org/user/102218)
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>This code, uses ::loadMultiple() to load the entities. But as far as I can tell, only really uses ID and revision_ID from the objects.</p>
<p><a href="https://git.drupalcode.org/project/entity_hierarchy/-/blob/3.x/src/Plugin/Validation/Constraint/ValidHierarchyReferenceConstraintValidator.php#L119">https://git.drupalcode.org/project/entity_hierarchy/-/blob/3.x/src/Plugin/Validation/Constraint/ValidHierarchyReferenceConstraintValidator.php#L119</a></p>
<p>If it could be converted to an EntityQuery, it would be significantly faster for entity saves; but I need someone with more knowledge about what it's doing to tell me it's feasible first.</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>If possible, use an entity query.</p>
issue