$result = \Drupal::entityQuery('group') ->condition('type', $type) ->range(0, 20000) ->accessCheck(FALSE) ->execute();
make sure to set accessCheck to FALSE or you'll get no results, entityQuery respects permissions and the drush user won't be running as any particular user.