SELECT `ce`.`entityId` AS `id`, COUNT(*) AS `commentCount`
FROM `ow_base_comment` AS `c`
LEFT JOIN `ow_base_comment_entity` AS `ce` ON (`c`.`commentEntityId` = `ce`.`id`)
WHERE `ce`.`entityType` = :entityType AND `ce`.`active` = 1 AND 1
GROUP BY `ce`.`entityId`
ORDER BY `commentCount` DESC, `id` DESC
LIMIT :first, :count

array (
'entityType' => 'blog-post',
'first' => 0,
'count' => 10,
)

0.000361

SELECT * FROM
(
SELECT `et`.*, COUNT(*) AS `count`, `t`.`label` AS `label` FROM `ow_base_entity_tag` AS `et`
LEFT JOIN `ow_base_tag` AS `t` ON ( `et`.`tagId` = `t`.`id` )
WHERE `et`.`entityType` = :entityType AND `et`.`active` = 1
GROUP BY `tagId`
ORDER BY `count` DESC
LIMIT :offset, :limit
) AS `t`
ORDER BY `t`.`label`