Skip to content
tezvyn:
Menu

Time-Series Databases: Optimized for Data Over Time

Source: Wikipedia: Time series databaseEasyHow cards are made

A Time-Series Database (TSDB) is a database optimized for data where time is the primary key. It's the backbone for monitoring systems, IoT devices, and financial apps. The footgun is using a regular database, which can't handle the unique query load.

Why it exists

General-purpose databases are not built for the unique workload of time-series data: constant, high-volume writes of timestamped records, and queries that aggregate data over time ranges. A relational database would struggle with indexing performance and storage bloat under this load. TSDBs were created to solve this specific problem efficiently.

The mental model

Think of a TSDB not as a set of complex, related tables, but as a hyper-efficient logbook. For every metric you're measuring (a server's CPU, a stock's price), it keeps a long, ordered list of timestamp-value pairs. Its main job is to write new entries to this list very fast and read back ranges or aggregates (like averages) just as quickly.

How it works

A TSDB's design makes time a first-class citizen. Time is always a key part of the index, making queries like "find all data points between last Tuesday and yesterday" extremely fast. They ingest high-volume writes by appending data, rather than performing complex updates. To manage storage, they use specialized compression algorithms that are effective on sequential data, like storing only the difference from the previous value instead of the full value each time.

When to use it

Use a TSDB for any application collecting measurements over time where your primary queries are time-based. This includes monitoring and observability (system metrics, application performance), IoT applications (sensor data from industrial equipment), and financial data (stock prices, trading volumes). If your question is "how did this metric change over the last N hours?", a TSDB is the right tool.

When not to use it

A TSDB is the wrong choice for data with complex relationships, which is the strength of a relational database. If you need to model customers, orders, and products with joins and foreign keys, a TSDB is not suitable. They are also not ideal for data that is frequently updated in place, as TSDBs are optimized for append-only writes.

One canonical example

A classic use case is monitoring server CPU utilization. An agent sends a data point every 10 seconds: {timestamp: 1677657600, metric: 'cpu.usage', host: 'web-01', value: 15.5}. A TSDB ingests millions of these from thousands of servers. An engineer can then instantly query it to graph the average CPU usage for all web servers over the past 24 hours, a task that would be slow and inefficient in a standard database.

Interview question

Which task is a Time-Series Database (TSDB) uniquely optimized to perform efficiently?

  • a.Managing a dataset where individual records are frequently updated in place.
  • b.Providing ACID compliance for complex transactional workloads across multiple tables.
  • c.Aggregating and analyzing millions of sensor readings collected every second over long periods.Correct
  • d.Storing and querying highly interconnected data with many foreign key relationships.
Why?

The card states TSDBs are optimized for "constant, high-volume writes of timestamped records, and queries that aggregate data over time ranges," making them ideal for sensor data. Option D describes a strength of relational databases, which TSDBs are explicitly not suited for due to their lack of support for complex relationships.

Just read this? Test yourself on what you have been reading.

Read the original → en.wikipedia.org

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on database — each one lists the topics its interview covers.

See open roles