num_elements()

The total number of points seen while calculating the CounterSummary. Only points with distinct times are counted, as duplicate times are usually discarded in these calculations.

  1. num_elements(
  2. summary CounterSummary
  3. ) RETURNS BIGINT

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

Required arguments

NameTypeDescription
summaryCounterSummaryThe input CounterSummary from a counter_agg call

Returns

NameTypeDescription
num_elementsBIGINTThe number of points seen during the counter_agg call

Sample usage

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