How do I limit the number of rows affected from the query?
See: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Database%21Query%21Select.php/class/Select/8.6.x

$query-&gt;range(0, 500);