Entity Query not returning all results
I added metadata to the query, running it as user 1, which allowed it to get all of the nodes:

$query = \Drupal::entityQuery('node')
    -&gt;condition('type', 'article')
    -&gt;addMetaData('account', \Drupal\user\Entity\User::load(1)); // Run the query as user 1.
$nids = $query-&gt;execute();

echo "count: " . $query-&gt;count()-&gt;execute() . "\n";

foreach ($storage-&gt;loadMultiple($nids) as $node){
  //do stuff
}


Also, since revisions are allowed for nodes, it was returning $nids as revision_id => entity_id as Berdir said in his comment.