Skip to content

timevector()

Create a timevector from time-value pairs for efficient time-series processing

Early access 1.3.0

Create a timevector object from time-value pairs. A timevector is a space-efficient intermediate representation that stores time-series data and can be passed to various analytic functions or used with pipeline operations.

Aggregate time-series data into a timevector:

SELECT timevector(time, weight) FROM samples;

Create a view to store pre-aggregated timevectors:

CREATE VIEW series AS
SELECT device_id, timevector(time, temperature) AS series
FROM sensor_data
GROUP BY device_id;

Pass a timevector directly to downsampling functions:

SELECT time, value::numeric(10,2)
FROM unnest((
SELECT lttb(timevector(time, value), 20)
FROM metrics
));

The syntax is:

timevector(
time TIMESTAMPTZ,
value DOUBLE PRECISION
) RETURNS Timevector
NameTypeDefaultRequiredDescription
timeTIMESTAMPTZ-Timestamp for each data point
valueDOUBLE PRECISION-Value at each timestamp
ColumnTypeDescription
timevectorTimevectorA timevector object containing the time-value pairs. Use with analytic functions, pipeline operations, or extract with unnest().