How load only some node fields? entity.query service is very handy when it comes to finding nodes with specific field values. Unfortunately all it returns are entity IDs and revision IDs.

In case in which result set is big it's really inefficient to load whole nodes if only data from specific fields is needed.

In D7 it was possible for example to use field_attach_load() function which (thankfully) has been removed in D8, as detailed in Fields are no longer handled individually and are bound to an entity type. The problem is that Drupal change log references loadFieldItems() and doLoadFieldItems() of FieldableEntityStorageControllerBase class neither of which exists in current release of D8.

What is the Drupal 8 way of loading data for specific node fields only?
I did some profiling with a query of 100,000 nodes, fetching the field myfield from all nodes of type mybundle.

Good: A dynamic query with addField()

$connection = \Drupal::database();
$query = $connection-&gt;select('node__field_myfield');
$query-&gt;condition('node__field_myfield.bundle', 'mybundle');
$query-&gt;addField('node__field_myfield', 'field_myfield_value');
$result = $query-&gt;execute();
$values = $result-&gt;fetchAll();


This runs in about 250 milliseconds.

Bad: An entity query with loadMultiple()

$query = \Drupal::entityQuery('node');
$query-&gt;condition('type', 'mybundle');
$node_storage = \Drupal::entityTypeManager()-&gt;getStorage('node');
$values = [];
$nids = $query-&gt;execute();
$nodes = $node_storage-&gt;loadMultiple($nids);
foreach($nodes as $node) {
  $values[] = $node-&gt;get('field_myfield')-&gt;getValue();
}


This took 3 minutes after a few repeated attempts when the cache was fully built. After a cache rebuild, it took more than half an hour.