How to get all the content types that don't have nodes?
I know that you can use the 'entity.manager' service to get all the available content types and then through a loop look for all the nodes for each content types. But this way is very long and involve many database queries.

This is the short way that I found to obtain this information:

// Getting the database connection.
$connection = \Drupal::service('database');
$query_content_types = "SELECT DISTINCT SUBSTR(name, 11) as type FROM config WHERE name LIKE 'node.type.%'";
// Creating a temporary table.
$content_types_temporary_table_name = $connection-&gt;queryTemporary($query_content_types);

$query = "SELECT node_type.type, COUNT(nid) AS total
          FROM $content_types_temporary_table_name node_type LEFT JOIN {node} USING(type)
          GROUP BY type
          HAVING COUNT(nid) = 0
          ORDER BY type ASC";

$result = $connection-&gt;query($query);
dpm($result-&gt;fetchCol('type'));