Time-series databases are purpose-built for storing and querying data points indexed by time. Whether you’re collecting server metrics, IoT sensor readings, application performance data, or financial tick data, a specialized time-series database will outperform a general-purpose database for these workloads.
M3DB, QuestDB, and TimescaleDB represent three distinct approaches to time-series data storage. M3DB is a distributed database designed as a Prometheus long-term store, QuestDB is a high-performance columnar database optimized for fast ingestion and SQL queries, and TimescaleDB extends PostgreSQL with time-series capabilities.
In this guide, we compare all three databases with Docker Compose configurations, query examples, and deployment instructions.
What Are Time-Series Databases?
Time-series databases (TSDBs) optimize for workloads where data is:
- Time-ordered — every record has a timestamp, and queries are typically time-range based
- Append-heavy — new data is constantly written, with rare updates or deletes
- Aggregation-friendly — queries often compute averages, sums, percentiles over time windows
- High-cardinality — many unique tag combinations (e.g., per-host, per-service metrics)
Unlike relational databases, TSDBs use specialized storage engines, compression algorithms, and indexing strategies to handle billions of data points efficiently.
M3DB
M3DB (4,890+ stars) is a distributed time-series database created by Uber and now part of the CNCF landscape. It was specifically designed as a long-term storage backend for Prometheus, with horizontal scaling, replication, and multi-tenant support.
Key Features
- Prometheus remote write/read — drop-in replacement for Prometheus long-term storage
- Horizontal scalability — add nodes to increase capacity and throughput
- Built-in replication — configurable replication factor for fault tolerance
- Multi-tenancy — isolate data by namespace with per-namespace retention policies
- Graphite compatibility — ingest and query Graphite-format metrics
Docker Compose Setup
| |
M3DB initialization (run once):
| |
Query Examples
PromQL query via M3Query:
| |
Pros and Cons
| Pros | Cons |
|---|---|
| Native Prometheus integration | Complex deployment with multiple components |
| Horizontal scalability | Steep operational learning curve |
| Built-in replication and fault tolerance | Smaller community than TimescaleDB |
| Multi-tenant with namespace isolation | Limited SQL query support |
QuestDB
QuestDB (6,200+ stars) is a high-performance, open-source time-series database with SQL support. It uses a custom columnar storage engine optimized for fast ingestion and analytical queries, making it ideal for financial market data, IoT telemetry, and application metrics.
Key Features
- SQL interface — standard SQL with time-series extensions (SAMPLE BY, LATEST ON)
- Columnar storage — optimized for analytical queries over large time ranges
- High ingestion rate — millions of rows per second on modern hardware
- InfluxDB Line Protocol — compatible with InfluxDB clients and tools
- PostgreSQL wire protocol — connect with any PostgreSQL-compatible tool
Docker Compose Setup
| |
Query Examples
Create a table and insert data:
| |
Time-series aggregation:
| |
Pros and Cons
| Pros | Cons |
|---|---|
| Fastest ingestion of the three | No built-in replication/HA |
| Standard SQL with TS extensions | Younger project, smaller ecosystem |
| Web Console for ad-hoc queries | Limited multi-node support |
| PostgreSQL and InfluxDB compatible | No native Prometheus integration |
TimescaleDB
TimescaleDB (18,000+ stars) extends PostgreSQL with automatic time-based partitioning (hypertables), continuous aggregates, and time-series functions. It gives you full PostgreSQL capabilities — joins, transactions, extensions — plus time-series optimizations.
Key Features
- Full PostgreSQL compatibility — use any PostgreSQL tool, driver, or extension
- Hypertables — automatic partitioning by time (and optional space partitioning)
- Continuous aggregates — pre-computed materialized views that update automatically
- Compression — columnar compression for historical data, reducing storage by 90%+
- Time-series functions — time_bucket, interpolate, gapfill, and more
Docker Compose Setup
| |
Query Examples
Create a hypertable:
| |
Continuous aggregate:
| |
Time-series query with gap filling:
| |
Pros and Cons
| Pros | Cons |
|---|---|
| Full PostgreSQL compatibility | Single-node write scalability limit |
| Largest ecosystem and community | Requires PostgreSQL knowledge |
| Continuous aggregates | Distributed edition requires license |
| Mature compression and retention policies | Heavier resource usage than QuestDB |
Comparison Table
| Feature | M3DB | QuestDB | TimescaleDB |
|---|---|---|---|
| GitHub Stars | 4,890+ | 6,200+ | 18,000+ |
| Query Language | PromQL, M3QL | SQL (TS extensions) | SQL (PostgreSQL) |
| Storage Engine | Custom distributed | Columnar | PostgreSQL heap + BRIN |
| Horizontal Scaling | ✅ Native | ⚠️ Limited | ⚠️ Enterprise only |
| Prometheus Integration | ✅ Native | ❌ | ❌ |
| PostgreSQL Compatible | ❌ | ✅ Wire protocol | ✅ Full |
| Built-in Replication | ✅ | ❌ | ✅ (via PostgreSQL) |
| Time-Series Functions | Basic | Good (SAMPLE BY, LATEST ON) | Excellent (time_bucket, gapfill) |
| Continuous Aggregates | ❌ | ❌ | ✅ |
| Data Compression | ✅ | ✅ | ✅ (columnar) |
| Web Console | ❌ | ✅ Built-in | Via pgAdmin/DBeaver |
| Best For | Prometheus long-term storage | High-speed ingestion, SQL analytics | General time-series with full SQL |
Choosing the Right Time-Series Database
Choose M3DB if: You’re already using Prometheus and need a scalable, distributed long-term storage backend. Its native PromQL support and horizontal scaling make it the natural choice for large-scale metrics infrastructure.
Choose QuestDB if: You need maximum ingestion throughput and want to query time-series data with standard SQL. The columnar storage engine and time-series SQL extensions make it ideal for financial data, IoT telemetry, and log analytics.
Choose TimescaleDB if: You want the full power of PostgreSQL combined with time-series optimizations. The hypertable abstraction, continuous aggregates, and PostgreSQL ecosystem make it the most versatile choice for teams that already use PostgreSQL.
Why Self-Host Your Time-Series Database?
Managed time-series services (Datadog, New Relic, InfluxDB Cloud) charge per metric, per gigabyte, or per query — costs that scale unpredictably as your monitoring needs grow. Self-hosting gives you:
Cost control — store billions of data points on commodity hardware without per-metric fees. TimescaleDB compression alone can reduce storage costs by 90% compared to raw PostgreSQL.
Data retention flexibility — define custom retention policies per metric type. Keep high-resolution data for recent periods and downsampled aggregates for historical analysis, all within the same database.
No vendor lock-in — standard SQL (QuestDB, TimescaleDB) or PromQL (M3DB) means you can migrate between platforms or integrate with any visualization tool without proprietary query languages.
For related monitoring infrastructure, see our Grafana Mimir vs Thanos vs Cortex Prometheus storage guide and our Prometheus alerting comparison.
FAQ
Can M3DB replace Prometheus entirely?
No. M3DB is designed as a long-term storage backend for Prometheus, not a complete replacement. You still need Prometheus (or the M3Coordinator) for metric collection, alerting, and service discovery. M3DB handles the storage and query layer for historical data.
Does QuestDB support real-time streaming ingestion?
Yes. QuestDB supports InfluxDB Line Protocol for real-time data ingestion over UDP or TCP, and a REST API for batch inserts. It can ingest millions of rows per second on modern hardware, making it suitable for high-frequency trading data and IoT sensor streams.
How does TimescaleDB compression work?
TimescaleDB compresses historical data by converting row-based storage to columnar format, applying dictionary encoding and delta encoding. You configure compression policies by time interval (e.g., compress data older than 7 days). Compressed data is typically 10-50x smaller than raw storage.
Can I migrate from InfluxDB to QuestDB or TimescaleDB?
QuestDB supports the InfluxDB Line Protocol, so you can redirect InfluxDB clients directly to QuestDB without code changes. For historical data migration, export InfluxDB data as line protocol or CSV and import into QuestDB or TimescaleDB.
Which database is best for IoT sensor data?
QuestDB is optimized for high-speed ingestion of time-stamped sensor readings with SQL analytics. TimescaleDB is better if you need to join sensor data with relational data (device metadata, location info) using full SQL. M3DB is less suited for IoT unless you’re already in a Prometheus monitoring ecosystem.
How do I back up a self-hosted time-series database?
M3DB has built-in snapshot-based backups to S3-compatible storage. QuestDB supports file-level backups of its data directory. TimescaleDB uses standard PostgreSQL backup tools (pg_dump, pg_basebackup) plus its own continuous archive backup features for point-in-time recovery.