time_delta()

The observed change in time. Calculated by subtracting the first observed time from the last observed time over the period aggregated. Measured in seconds.

2. time_delta(

4. summary CounterSummary

6. ) RETURNS DOUBLE PRECISION

For more information about counter aggregation functions, see the hyperfunctions documentation.

Required arguments

Name Type Description
summary CounterSummary The input CounterSummary from a counter_agg call

Returns

Name Type Description
time_delta DOUBLE PRECISION The total duration in seconds between the first and last observed times in the CounterSummary

Sample usage

2. SELECT

4. id,

6. bucket,

8. time_delta(summary)

10. FROM (

12. SELECT

14. id,

16. time_bucket('15 min'::interval, ts) AS bucket,

18. counter_agg(ts, val) AS summary

20. FROM foo

22. GROUP BY id, time_bucket('15 min'::interval, ts)

24. ) t