How to aggregate (eg. sum) large ammount of data

I’m collecting large amounts of netflow and sflow data. Let’s say 10KK of flows ( -> rows) per 5 minute interval. Is there a way to make InfluxDB aggregate that fast? I’d like to display data in Grafana using query

SELECT sum(value) FROM table…

but obviously, the sum operation is very slow. How would you approach it? Is there any way to leverage InfluxDB here? My only idea is to agregate flows per display use cases and store less of them.

Thanks!