counter_zero_time()

The time at which the counter value is predicted to have been zero based on the least squares fit line computed from the points in the CounterSummary.

  1. counter_zero_time(
  2. summary CounterSummary
  3. ) RETURNS TIMESTAMPTZ

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

Required arguments

NameTypeDescription
summaryCounterSummaryThe input CounterSummary from a counter_agg call

Returns

NameTypeDescription
counter_zero_timeTIMESTAMPTZThe time at which the counter value is predicted to have been zero based onthe least squares fit of the points input to the CounterSummary

Sample usage

  1. SELECT
  2. id,
  3. bucket,
  4. counter_zero_time(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