Load all titles and body text from one content type into array
If yau have lots of node's than its difficult load all nodes at a time and also , to get only title and body, its not fair to load complete node.
Rather than load node and get values, we can use select query and fetch required values.

I am using cache concept here, once your query loaded, set it in cache untill any node values changes or any new node creates.
Use node hooks to remove cache for "node_data"
Below is the query:

  $nodedata = array();
  // Check cache exists
  $cache_node = \Drupal::cache()-&gt;get('node_data');
  if ($cache_node) {
    $array = $cache_node-&gt;data;
    $nodedata = json_decode($array, TRUE);
  }
  else {
    // Query for node title and body.
    $connection = \Drupal::database();
    $query = $connection-&gt;select('node', 'n');
    $query-&gt;leftJoin('node__body', 'b', 'b.entity_id = n.nid');
    $query-&gt;leftJoin('node_field_data', 't', 't.nid = n.nid');
    $query-&gt;fields('t', array('title'));
    $query-&gt;fields('b', array('body_value'));
    $query-&gt;condition('n.type', 'glossary', '=');
    $result = $query-&gt;execute()-&gt;fetchAll();
    foreach ($result as $key =&gt; $value) {
      $nodedata[] = array(
        'node_title' =&gt; $value-&gt;title,
        'node_body' =&gt; $value-&gt;body_value,
      );
    }
    // Set Cache.
    \Drupal::cache()-&gt;set('node_data', json_encode($nodedata));
  }
  dsm($nodedata);