Optimizing count queries by not using a derived table when there is no
group by nor distinct clause