Get pure SQL from Drupal::entityQuery
With debug tag (devel module is mandatory) we can print the raw sql. 

$query = \Drupal::entityQuery('foo')-&gt;condition('bar', 'xyz')-&gt;addTag('debug');
$ids = $query-&gt;execute();