Differently from what stated in the other answer for Drupal 8.0.6, there is a field for the node ID, in Drupal 8.1.3.
With Drupal 8.1.3, I followed these steps:
- I created a view of taxonomy terms, limiting them to the ones of just a vocabulary (in my case Blog categories)
- As relationship, I added Content using field_blog_category, where field_blog_category is the field I added to a content type I created
- I checked Use aggregration
- I added ID (listed under the Content category) as new field
- I set Aggregration type to Count for the new field (by clicking on Aggregration settings for that field)
What I got was the following one (as seen from the preview).
Following the steps I listed, but using UUID as new field (still listed under the Content category), I would have obtained the same result.
As expected, also the resulting query didn't change much, using the node ID or its UUID.
Using the node ID
SELECT taxonomy_term_field_data.name AS taxonomy_term_field_data_name, COUNT(field_blog_category_taxonomy_term_field_data.nid) AS field_blog_category_taxonomy_term_field_data_nid, MIN(taxonomy_term_field_data.tid) AS tid, MIN(field_blog_category_taxonomy_term_field_data.nid) AS field_blog_category_taxonomy_term_field_data_nid_1
FROM
{taxonomy_term_field_data} taxonomy_term_field_data
LEFT JOIN {node__field_blog_category} node__field_blog_category ON taxonomy_term_field_data.tid = node__field_blog_category.field_blog_category_target_id AND node__field_blog_category.deleted = '0'
LEFT JOIN {node_field_data} field_blog_category_taxonomy_term_field_data ON node__field_blog_category.entity_id = field_blog_category_taxonomy_term_field_data.nid
WHERE (( (taxonomy_term_field_data.vid IN ('blog_categories')) ))
GROUP BY taxonomy_term_field_data_name
LIMIT 21 OFFSET 0
Using the node UUID
SELECT taxonomy_term_field_data.name AS taxonomy_term_field_data_name, COUNT(field_blog_category_taxonomy_term_field_data__node.uuid) AS field_blog_category_taxonomy_term_field_data__node_uuid, MIN(taxonomy_term_field_data.tid) AS tid, MIN(field_blog_category_taxonomy_term_field_data.nid) AS field_blog_category_taxonomy_term_field_data_nid
FROM
{taxonomy_term_field_data} taxonomy_term_field_data
LEFT JOIN {node__field_blog_category} node__field_blog_category ON taxonomy_term_field_data.tid = node__field_blog_category.field_blog_category_target_id AND node__field_blog_category.deleted = '0'
LEFT JOIN {node_field_data} field_blog_category_taxonomy_term_field_data ON node__field_blog_category.entity_id = field_blog_category_taxonomy_term_field_data.nid
INNER JOIN {node} field_blog_category_taxonomy_term_field_data__node ON field_blog_category_taxonomy_term_field_data.nid = field_blog_category_taxonomy_term_field_data__node.nid
WHERE (( (taxonomy_term_field_data.vid IN ('blog_categories')) ))
GROUP BY taxonomy_term_field_data_name
LIMIT 21 OFFSET 0