Time-series data
Oracle
-- Range partitioning by date:
CREATE TABLE measurements (
ts TIMESTAMP, sensor_id NUMBER, value NUMBER)
PARTITION BY RANGE (ts)
INTERVAL (NUMTODSINTERVAL(1,'DAY'))
( PARTITION p0 VALUES LESS THAN (TIMESTAMP '2026-01-01 00:00:00') );In Oracle, time-series data is usually managed with RANGE (INTERVAL) partitioning; new partitions are created automatically and old partitions are easily dropped (partition pruning speeds up queries). Compression (ILM/ADO) and materialized views for aggregation are also used.
PostgreSQL
-- Hypertable with the TimescaleDB extension:
CREATE EXTENSION IF NOT EXISTS timescaledb;
CREATE TABLE measurements (ts TIMESTAMPTZ, sensor_id INT, value DOUBLE PRECISION);
SELECT create_hypertable('measurements', 'ts');
-- Summarize with a continuous aggregate.PostgreSQL can hold time series with native partitioning (PARTITION BY RANGE); the TimescaleDB extension adds hypertables with automatic time-based chunking, compression, retention policies and continuous aggregates. It is a common solution for large IoT/metrics workloads.
MySQL
-- RANGE partitioning by date:
CREATE TABLE measurements (
ts DATETIME, sensor_id INT, value DOUBLE,
PRIMARY KEY (ts, sensor_id))
PARTITION BY RANGE (TO_DAYS(ts)) (
PARTITION p2026_01 VALUES LESS THAN (TO_DAYS('2026-02-01')),
PARTITION pmax VALUES LESS THAN MAXVALUE);MySQL offers no dedicated time-series engine; RANGE partitioning (with TO_DAYS/UNIX_TIMESTAMP) allows fast dropping of old data and partition pruning. For high-volume time series, external solutions (TimescaleDB, InfluxDB) or summary tables are usually preferred.
SQL Server
-- Partitioned table (partition function + scheme) or
-- system-versioned temporal table (history kept automatically):
CREATE TABLE dbo.measurements (
id INT PRIMARY KEY, value DECIMAL(10,2),
valid_from DATETIME2 GENERATED ALWAYS AS ROW START,
valid_to DATETIME2 GENERATED ALWAYS AS ROW END,
PERIOD FOR SYSTEM_TIME (valid_from, valid_to))
WITH (SYSTEM_VERSIONING = ON);SQL Server manages time series by partitioning with a partition function/scheme; this provides pruning and fast archiving for data spanning large date ranges. In addition, system-versioned temporal tables (SYSTEM_VERSIONING) automatically keep row change history and allow point-in-time querying (FOR SYSTEM_TIME).
MongoDB
// Time-series collection (MongoDB 5.0+):
db.createCollection("measurements", {
timeseries: {
timeField: "ts",
metaField: "sensor_id",
granularity: "seconds"
}
})Time-series collections, introduced in MongoDB 5.0, automatically store data in a compressed, column-like (bucketed) format by time and meta field; they reduce disk and index usage and speed up range queries. timeField is mandatory; metaField (source/tag) and granularity determine performance.
Redis
# Requires the RedisTimeSeries module (Redis Stack).
# Create a series with a retention period:
TS.CREATE sensor:1 RETENTION 86400000 LABELS type temperature
# Add a sample (with an automatic timestamp):
TS.ADD sensor:1 * 23.5Core Redis has no time-series type; the RedisTimeSeries module (Redis Stack) provides high-speed sample ingestion with TS.CREATE/TS.ADD, automatic retention (RETENTION), downsampling (TS.CREATERULE) and label-based range queries with TS.RANGE/TS.MRANGE. Without the module, it is emulated with a Sorted Set.
Elasticsearch
# Data stream: automatically rolling indexes for time series
PUT _index_template/measurements-tpl
{ "index_patterns": ["measurements*"], "data_stream": {},
"template": {
"settings": { "index.mode": "time_series", "index.routing_path": ["sensor_id"] },
"mappings": { "properties": {
"@timestamp": { "type": "date" },
"sensor_id": { "type": "keyword", "time_series_dimension": true },
"temperature": { "type": "double", "time_series_metric": "gauge" } } } } }
PUT _data_stream/measurementsElasticsearch manages time-series data with data streams; new backing indexes are created automatically over time (rollover), and ILM moves old data through hot/warm/cold tiers and deletes it. TSDS (index.mode: time_series) provides storage optimizations specific to metrics data; at least one time_series_dimension field, an index.routing_path pointing to it, and a @timestamp field are mandatory (otherwise the template is rejected).