Counting entities the fastest way (at least the fastest way I found)
function countEntities(EntityManagerInterface $em, string $className): int
{
return current($em->createQueryBuilder()
->select('count(c.id)')
->from($className, 'c')
->getQuery()
->getSingleResult());
}