In Drupal 7 if you want a list with the content types that don't have nodes you can do it with the following query:
SELECT type, name, COUNT(nid) as total
FROM node_type LEFT JOIN node USING(type)
GROUP BY type
HAVING total = 0
ORDER BY name
But in Drupal 8 we don't have the {node_type} table and you can't have access to all the available content types unless you use the 'entity.manager' service or you go to look inside the {config} table that have a column named name, but in the name column you will find this:
node.type.CONTENT_TYPE_MACHINE_NAME1
node.type.CONTENT_TYPE_MACHINE_NAME2
There is not an easy way to get the information from this table.
I found an example in the Entity Query support for aggregated queries page:
Let's assume you want the amount of nodes per node type.
$query = Drupal::entityQueryAggregate('node'); $result = $query ->groupBy('type') ->aggregate('nid', 'COUNT') ->execute();
But only works for content types with more than 1 node, why? Again there is not way to find content types in the database that don't have nodes.
I really don't know the reason for this missing important part (and I can't find it) but I think that this is very important because the only way now to obtain the content type label is through the 'entity.manager' service.
In short, how to get all the content types that don't have nodes?