ClickhouseBuilder icon indicating copy to clipboard operation
ClickhouseBuilder copied to clipboard

Optimize count calculation

Open tw2066 opened this issue 1 year ago • 1 comments

Optimize the group by count calculation

tw2066 avatar Jun 26 '23 06:06 tw2066

Prevents groupby from returning too many numbers, and optimizes the number directly to the database

Before optimization, you need to calculate the quantity

SELECT count() as `count` FROM `test` WHERE `id` != 12 GROUP BY `goods_id`

After optimization, directly return the quantity

SELECT count() as `count` FROM (SELECT `goods_id` FROM `test` WHERE `id` != 12 GROUP BY `goods_id`)

tw2066 avatar Jun 26 '23 06:06 tw2066