Problem with a query
There's nothing different from 7.x with db_query(), it returns a result set where you can fetch results from or loop over it. Refer to the database API documentation.

However, there are even less reasons for doing a direct database query in 8.x than in 7.x, and doing the query by hand is very likely going to be more complicated because of the data tables.

Use entity query instead:

&lt;?php
$uids = \Drupal::entityQuery('user')
  -&gt;execute();
?&gt;


Executing an entity query always returns entity IDs which can then be loaded:

&lt;?php
$users = \Drupal::entityManager()-&gt;getStorage('user')-&gt;loadMultiple($uids);
// Shorthand if you know that you have users:
$users = \Drupal\user\Entity\User::loadMultiple($uids);
?&gt;