How to optimize summary and plotting of many data points

I am logging solar production and consumption of appliances at a very detailed 10sec data point interval basis, means I have a lot of data in my influx data base.

That all works great for summaries (sum data) and plotting up to a few month time range and but is obviously getting slower the more data I ask to consolidate… (running on a Raspberry PI, 4GB memory).

And beyond that it fails with N/A – timeout or some thing? Not sure at what level that happens.
I can query about a 60 day summary of one data field before it fails…

Anyhow, is there a smarter way to generate (may be automatic??) say weekly (or some how dynamic) averages or sum data to work on if for example a annual summary is requested? And plotting of averages?

So far I can only think about programming a custom query to create new consolidated tables – but it’s tedious.

Thanks for any tips!