As already discussed in speed up long running query this query is rather slow.
My environment means that influxdb is running on a Raspberry Pi 4b only which is not optimal.
My powermeter produces roughly around 10000 data points per day. Therefore summarizing needs a lot of time.
I prefer now to do this “on the fly” with a Task that runs every day.
To handle already written points (sum up the energy consumption per day) I run over another problem with the query that I don’t want to be unmentioned (for others how will read this thread):
The problem is located in the elapsed function.
Elapsed is calculating the time difference between the current and last data point and writes it into the row of the current datapoint. This means it “looks” back and not forward which is important for energy calculation.
Calculation of the used energy means the following:
The power meter generates 1000 pulses for every 1kWh. In my case I have a calculation done in my home automation that calculates from pulses the power from pulse to pulse. If the power changes (and it does with every incomming pulse) this means that this is the power my house needs at the moment (up to the next pulse).
This means that I would rather need an elapsed function that looks foreward, e.g. that calculates the difference between two rows and stores it at the first row. This woul mean not to omit the first row and to omit the last row.
Therefore I used for my task queries the events.duration function now, see:
https://docs.influxdata.com/flux/v0.x/stdlib/contrib/tomhollingworth/events/duration/
for details of the query pls. have a look in thread mentioned above.