How does \Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection::getSelectCountSql() work?

Context: How does \Magento\Framework\Data\Collection\AbstractDb::getSize() work?

Details: How does \Magento\Framework\Data\Collection\AbstractDb::getSelectCountSql() work?

$countSelect->assemble() result:

SELECT COUNT(*) FROM `eav_attribute` AS `main_table`
	INNER JOIN `eav_entity_type` AS `entity_type`
		ON main_table.entity_type_id = entity_type.entity_type_id
	LEFT JOIN `eav_entity_attribute`
		ON main_table.attribute_id = eav_entity_attribute.attribute_id
	INNER JOIN `catalog_eav_attribute` AS `additional_table`
		ON main_table.attribute_id = additional_table.attribute_id
WHERE (`entity_type_code` = 'catalog_product') AND (`attribute_set_id` != '')

Details: How does \Zend_Db_Select::reset() work?

$countSelect->assemble() result:

SELECT COUNT(DISTINCT main_table.attribute_id) FROM `eav_attribute` AS `main_table`
	INNER JOIN `eav_entity_type` AS `entity_type` 
		ON main_table.entity_type_id = entity_type.entity_type_id
	LEFT JOIN `eav_entity_attribute` 
		ON main_table.attribute_id = eav_entity_attribute.attribute_id
 	INNER JOIN `catalog_eav_attribute` AS `additional_table` 
 		ON main_table.attribute_id = additional_table.attribute_id 
WHERE (`entity_type_code` = 'catalog_product') AND (`attribute_set_id` != '')