“Timescale” Database
Time-series data is data that collectively represents how a system, process, or behaviour changes over time. Timescale database is one of the time-series databases. It is an open-source database designed to make SQL scalable. Timescale is an extension of the PostgreSQL database, providing automatic partitioning across time and space (partitioning key), as well as full SQL support.
Using TimescaleDB helps in scaling PostgreSQL for time-series data via automatic partitioning across time and space. In PostgreSQL, we have a table to store data but TimescaleDB has a table that looks like a regular table but is a virtual view of many individual tables comprising the actual data.
This single-table view is a hyper table that comprises many chunks, chunks are created by partitioning the hypertables data in either one or two dimensions: by a time interval, and by an (optional) “partition key” such as device id, location, user id, etc.
Hypertables are the heart of TimescaleDB and allow TimescaleDB to work with time-series data. The presence of chunks and hypertables in TimescaleDB helps in storing and querying a huge amount of data(petabytes).
Now, let’s see how we can create and query hyper table and chunks.
— Step1:Add extension TimescaleDB to the current database.