Convert db_query in EntityFieldQuery
As long as you only query for fields, entity query does the joins automatically for you.

Note that entity query can only return entity ID's, you then need to load them.

$ids = \Drupal::entityQuery('user')
  -&gt;condition('status', 1)
  -&gt;condition('roles', 'pubblisher')
  -&gt;execute();

$users = User::loadMultiple($ids);