Skip to content

Time-Series Data Ingestion and Querying

What is Time-Series Data

Time-series data refers to a sequence of data points collected over time intervals, typically consisting of measurements taken at successive points in time. This type of data is analyzed to track changes, recognize trends, and predict future patterns based on historical data

Type of Time-series in ClapDB

timestamp, timestmaptz, date, time, interval please check data types

The working sceniaroes of Time-Series Data

Time-series data is generally used for selection, mainly to choose intervals or to segment into buckets according to intervals, in order to analyze the trend changes of other indicators.

Time-Series Data Ingestion

DDL

DDL should ensure that a time-series table has only one time related column, and the column should be indexed, just like normal pg table.

Ingesting

Ingesting time-series data is same as other type data in ClapDB

Time-Series Data Querying

Query distinct count of a time range.

Let’s see the following fake example.

select distinct(id) from fake_table where time_columnar > now() - interval '1 hour' and time_columnar_2 < now();

group by time interval is very important in Time-series Query, there are 2 functions can be used:

  • date_trunc
  • date_bin

just like PostgreSQL;

examples:

SELECT date_trunc('day', time), count(*) from line_changes group by date_trunc('day', time);
SELECT date_bin('15 minutes'::interval,time, '2022-11-05'::timestamp), count(*) from line_changes group by date_bin('15 minutes'::interval,time, '2022-11-05'::timestamp);

Time-Series Functions and Operators

TODO