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.

  1. time_delta(
  2. summary CounterSummary
  3. ) RETURNS DOUBLE PRECISION

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

Required arguments

NameTypeDescription
summaryCounterSummaryThe input CounterSummary from a counter_agg call

Returns

NameTypeDescription
time_deltaDOUBLE PRECISIONThe total duration in seconds between the first and last observed times in the CounterSummary

Sample usage

  1. SELECT
  2. id,
  3. bucket,
  4. time_delta(summary)
  5. FROM (
  6. SELECT
  7. id,
  8. time_bucket('15 min'::interval, ts) AS bucket,
  9. counter_agg(ts, val) AS summary
  10. FROM foo
  11. GROUP BY id, time_bucket('15 min'::interval, ts)
  12. ) t