A time series database (TSDB) is designed to efficiently store, retrieve, and manage data that is organized and indexed by time. It traditionally works like a columnar key-value database but has time stamps as keys. If the timestamp alone can’t uniquely identify rows, we can combine it with another key (or keys) to form a composite key.
Time series data usually includes timestamped values such as stock prices, sensor readings, temperature measurements, network traffic data, etc. It’s usually represented by a graph, as shown below.
This kind of data can be stored in a TSDB, as shown in the table below. Row 1 has the “2023-08-27 12:10:16” timestamp, which is the identifier or key for this row. Against this key, we have the crypto symbol “ETH” and a “+3.5” gain.
We can turn regular relational databases into TSDBs using add-ons, but since recently, standalone solutions in the market can provide a plug-and-play setup experience.
Note: The data in the table and the chart above is an example. It doesn’t reflect real-world data.
With their rise in popularity, the number of options available for time series databases has also increased dramatically. Some of the more popular options include:
Amazon Timestream
CrateDB
InfluxDB
TimescaleDB
Prometheus
Some of these options turn regular databases into time series databases, while others are standalone options.
TSDBs provide far lower latency and storage requirements than relational databases, making it useful for real-time applications. We can use a regular relational database to store and manage time series data, but using a TSDBs provide us with a few advantages:
Time-based indexing: They’re optimized for time-based indexing and querying, which is crucial for time series data.
Aggregation: TSDBs provide built-in functions for summarizing data over time intervals.
Ease of use: TSDBs are easier to set up and manage for time series workloads.
Cost efficiency: They can be more cost-effective for storing and processing time series data.
Scalability: Many TSDBs scale horizontally with relative simplicity to handle consumption needs.
Specialized language: They have specialized query languages for time-related operations.
However, they’re inefficient for general data storage needs because they’re a niche use-case-specific type of database. So, it makes sense to use TSDBs only in combination with other databases in time-sensitive applications.